URI Online Judge Solution | 1040 – Average 3

Keep check on the line “Calculate the average with weights 2,3,4 e 1” actually that means you have to use the avergae formula like this

n1*2+n2*3+n3*4+n4*1/(2+3+4+1)

and check this line “followed by the typed score”..You have to input this value before showing

#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    float a,b,c,d,z,_average,recalculate,exam,exam_score;

    scanf("%f %f %f %f",&a,&b,&c,&d);

    _average=(((a*2)+(b*3)+(c*4)+(d*1))/10);

    printf("Media: %.1f\n",_average);


    if(_average>=7.0)
    {
        printf("Aluno aprovado.\n");
    }
    if(_average<5.0)
    {
        printf("Aluno reprovado.\n");
    }
    if(_average>=5.0 && _average<=6.9)
    {
        printf("Aluno em exame.\n");
        exam=z;

        scanf("%f",&exam_score);
        printf("Nota do exame: %.1f\n",exam_score);

        recalculate=(_average+exam_score)/2;


        if(recalculate>=5.0)
        {
            printf("Aluno aprovado.\n");
            printf("Media final: %.1f\n",recalculate);
        }
        else if(recalculate<=4.9)
        {
            printf("Aluno reprovado.\n");
            printf("Media final: %.1f\n",recalculate);
        }

    }


    return 0;
}

Note: URI,UVA,codeforces and in various online judges there is presentation error if you dont give new line after every output value that means in C you have to give “\n” in every printf/output line otherwise it will show “Presentation Error” on the OJ’s

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *