URI / BEE CROWD 1117 - Score Validation - Solution in C,C++,Python | URI - BEECROWD - BEE 1117 Solution in C,C++,Python

URI / BEE CROWD 1117 - Score Validation - Solution in C,C++,Python | URI - BEECROWD - BEE 1117 Solution in C,C++,Python

                                                                                        beecrowd | 1117

Score Validation

Adapted by Neilor Tonin, URI  Brazil

                                                                                             Timelimit: 1


URI / BEE CROWD 1117 - Score Validation - Solution in C,C++,Python | URI - BEECROWD - BEE 1117 Solution in C,C++,Python:

Write a program that reads two scores of a student. Calculate and print the average of these scores. Your program must accept just valid scores [0..10]. Each score must be validated separately.

Input

The input file contains many floating-point numbers​​, positive or negative. The program execution will be finished after the input of two valid scores.

Output

When an invalid score is read, you should print the message "nota invalida".
After the input of two valid scores, the message "media = " must be printed followed by the average of the student. The average must be printed with 2 numbers after the decimal point.

Input SampleOutput Sample

-3.5
3.5
11.0
10.0

nota invalida
nota invalida
media = 6.75

                                                          Demonstration:

This program takes user inputs . Then check the conditions for each test case contains two integer number x and y where the range is between 0 to 10.
If condition holds true then calculate the average by summing two numbers and divided it by 2 i.e, (x+y)/2

Finally print the result.

N.B: Don't copy paste the code as same. Just try to understand it and try yourself.

  URI / BEE 1117 Solution in C :   

  URI / BEECROWD Online Judge 1117 Solve  in C :                                          

#include <stdio.h>
int main()
{
    double a,b,c=0,d=0;
    while(1)
    {
        if(d==2)
            break;
        scanf("%lf", &a);
        if(a>=0 && a<=10)
        {
            d++;
            c+=a;
        }
        else
            printf("nota invalida\n");
    }
    b=c/2.00;
    printf("media = %.2lf\n", b);
    return 0;
}

0 Response to URI / BEE CROWD 1117 - Score Validation - Solution in C,C++,Python | URI - BEECROWD - BEE 1117 Solution in C,C++,Python

Post a Comment