Hey this is my homework assignment. I'm stuck on part c; which asks me to reduce the grade by 1 letter if assignement 1 or 2 is failed. I'm not sure how to do this because i can only express it if the value was to be presented as an integer; rather then a letter grade. Here is what i have so far:
Code:
#include<stdio.h>
#include<conio.h>
int main ()
{
int test1,test2,ass1,ass2;
float av1,av2;
printf("Please enter your first four marks\n");
scanf("%d%d%d%d",&test1,&test2,&ass1,&ass2);
av1=(test1+test2+ass1+ass2)/4;
av2=av1-10;
printf("Your average is %f\n", av1);
if(test1<50 && test2<50){
printf("The letter is F");
}
if(av1<50){
printf("The letter is F");
}
else if(ass1<50){
printf("The number %f is reduced by one grade",av1);
}
else if(ass2<50){
printf("The number %f is reduced by one grade",av1);
}
else if(av1>50 && av1<59){
printf("Your mark is D");
}
else if(av1>60 && av1<69){
printf("Your mark is C");
}
else if(av1>70 && av1<79){
printf("Your mark is B");
}
else if(av1>80 && av1<100){
printf("Your mark is A");
}
else
{
printf("The number is invalid");
}
getch();
}
the assignment:- Write the algorithm (pseudocode) for the following program definition: Read in a set of 4 marks for a student, representing two test marks followed by two assignment marks. Calculate and print a final grade, using the following information:
a)All the marks are out of 100, and are equally weighted in the average.b)Grades are assigned based on A = 80 – 100, B = 70 – 79, C = 60 – 69, D = 50 – 59, F = 0 – 49c)If the student fails (i.e. mark < 50) either or both assignments, the grade is reduced by 1 (e.g. B becomes C).d)If the student fails either or both tests, the mark will be F.
*you must use nested ifs*