Show me how Write a program that prompts the user for a stud
Show me how Write a program that prompts the user for a student grade average (e.g. 86.7) and outputs what the letter grade should be. Ensure that your program notifies the user if he/she enters a non-valid average (i.e. one greater than 100 or less than 0).
Solution
Assume Grade A if marks >75
Grade B if marks between 60-75
Grade C if marks between 40-60
Fail if Grade<40
---------------Code -------------------------------------------
#include <stdio.h>
int main(void)
{
float a;
printf(\" Enter the student grade average :\");
scanf(\"%f\", &a);
int grade =int(a); //convert float to integer
if(grade<0 || grade>100)
printf(\"You entered invalid grade average.Please enter value between 0 and 100\");
else{
if
(grade >=75)
{
System.out.println(\"Grade is A\");
}
else
if
((grade >= 60)&&( grade <75 ))
{
System.out.println(\"Grade is B\");
}
if
((grade >=40 )&&(grade<60))
{
System.out.println(\"Grade is C\");
}
else
if
(grade <40 )
{
System.out.println(\" Sorry you have no part here,FAILED\");
}
}
return 0;
}
