#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define P 50
#define H3 65
#define H2b 70
#define H2a 75
#define H1 80
#define MAX 10
typedef char name_t[ MAX] ;
typedef struct {
name_t name;
double mark;
double outof;
double weight;
double total;
} assesment_t;
int main( int argc, char ** argv) {
assesment_t Subject[ MAX] ;
/*---------------------------------------------------------------------------*/
printf ( "\n \n Enter information in this order separated by a space\n " ) ; printf ( "When all info entered, press enter\n " ) ; printf ( "(Include exam but enter the Mark bit as 0):\n " ) ; printf ( "Name Mark OutOf Weight\n \n " ) ; /*---------------------------------------------------------------------------*/
int i, n;
double total = 0 ;
/*---------------------------------------------------------------------------*/
for ( i
= 0 ; ( scanf ( "%s %lf %lf %lf" , Subject
[ i
] .
name ,& Subject
[ i
] .
mark ,& Subject
[ i
] .
outof ,& Subject
[ i
] .
weight ) ) == 4 ; i
++ ) {
if ( i == 0 ) {
printf ( "Name\t Mark\t Out of\t Weight\t Total" ) ; }
Subject[ i] .total = ( ( Subject[ i] .mark / Subject[ i] .outof ) * Subject[ i] .weight ) ;
printf ( "\n %s\t %2.1lf\t %2.1lf\t %2.2lf\t %2.2lf" , Subject
[ i
] .
name , Subject
[ i
] .
mark , Subject[ i] .outof , Subject[ i] .weight , Subject[ i] .total ) ;
}
/*---------------------------------------------------------------------------*/
n = i;
for ( i = 0 ; i < n; i++ ) {
total += Subject[ i] .total ;
}
printf ( "\n Total: %3.2lf\n \n " , total
) ; /*---------------------------------------------------------------------------*/
double grade, result;
for ( grade = 23 ; grade <= 60 ; grade++ ) {
result = ( grade / Subject[ i- 1 ] .outof ) * Subject[ i- 1 ] .weight ;
if ( total + result > P && ( total + result - 1 ) < P)
printf ( "minimum of %2.0lf is needed for FAIL\n " , grade
) ; else if ( total + result > H3 && ( total + result - 1 ) < H3)
printf ( "minimum of %2.0lf is needed for P\n " , grade
) ; else if ( total + result > H2b && ( total + result - 1 ) < H2b)
printf ( "minimum of %2.0lf is needed for H3\n " , grade
) ; else if ( total + result > H2a && ( total + result - 1 ) < H2a)
printf ( "minimum of %2.0lf is needed for H2b\n " , grade
) ; else if ( total + result > H1 && ( total + result - 1 ) < H1)
printf ( "minimum of %2.0lf is needed for H2a\n " , grade
) ; else if ( total + result > H1 && ( total + result - 1 ) < H1)
printf ( "minimum of %2.0lf is needed for H1\n " , grade
) ; else
;
}
/*---------------------------------------------------------------------------*/
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hdGguaD4KCiNkZWZpbmUgUCA1MAojZGVmaW5lIEgzIDY1CiNkZWZpbmUgSDJiIDcwCiNkZWZpbmUgSDJhIDc1CiNkZWZpbmUgSDEgODAKI2RlZmluZSBNQVggMTAKCnR5cGVkZWYgY2hhciBuYW1lX3RbTUFYXTsKdHlwZWRlZiBzdHJ1Y3QgewogICAgbmFtZV90IG5hbWU7CiAgICBkb3VibGUgbWFyazsKICAgIGRvdWJsZSBvdXRvZjsKICAgIGRvdWJsZSB3ZWlnaHQ7CiAgICBkb3VibGUgdG90YWw7Cn0gYXNzZXNtZW50X3Q7CgoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKiphcmd2KXsKICAgIGFzc2VzbWVudF90IFN1YmplY3RbTUFYXTsKICAgIC8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8gICAgCiAgICBwcmludGYoIlxuXG5FbnRlciBpbmZvcm1hdGlvbiBpbiB0aGlzIG9yZGVyIHNlcGFyYXRlZCBieSBhIHNwYWNlXG4iKTsKICAgIHByaW50ZigiV2hlbiBhbGwgaW5mbyBlbnRlcmVkLCBwcmVzcyBlbnRlclxuIik7CiAgICBwcmludGYoIihJbmNsdWRlIGV4YW0gYnV0IGVudGVyIHRoZSBNYXJrIGJpdCBhcyAwKTpcbiIpOwogICAgcHJpbnRmKCJOYW1l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