05 September 2015

UVA 11777 - Automate the Grades

#include<iostream>
#include<stdio.h>
using namespace std ;

int term(int e, int g, int h)
{
    int m  ,x ;
  if((e>=h)&&(g>=h)) m = (e+g)/2 ;
  else if((e>=g)&&(h>=g)) m = (e+h)/2 ;
  else if((g>=e)&&(h>=e)) m = (g + h)/2 ;
    //int l = m/2 ;
    return m ;
}
int main()
{
    int i ,j , k ;
    cin>>i ;
    int a,b,c,d,e,f,g,h ;
    for(j=1 ; j<=i ; j++)
    {
       cin>>a>>b>>c>>d>>e>>g>>h ;
        int avg = term(e,g,h) ;
        k = a + b + c + d + avg ;
        if(k>=90)  cout<<"Case "<<j<<": "<<"A" ;
        else if((k>=80)&&(k<90)) cout<<"Case "<<j<<": "<<"B" ;
        else if((k>=70)&&(k<80)) cout<<"Case "<<j<<": "<<"C" ;
        else if((k>=60)&&(k<70)) cout<<"Case "<<j<<": "<<"D" ;
        else if(k<60) cout<<"Case "<<j<<": "<<"F" ;
        //if(j<i)
            cout<<endl ;
    }

    return 0 ;
}

No comments:

Post a Comment

UVA 10679 - I Love Strings!!