1, give a percentile grade, require output grade a,b,c,d,e. More than 90 points for a,80~89 divided into b,70~79 divided into c,60~69 divided into d,60 sub-division of the following E. Requirements:
(1) using the IF statement and the switch statement respectively;
(2) When entering illegal data (such as negative numbers), you should give the "input data error" information
Switch Statement implementation:
#include <stdio.h>
int main ()
{
int score;
printf ("Input student's score: \ n");
scanf ("%d", &score);
if (score<0 | | score>100)
{
printf ("Data entered illegally!\n");
}
Else
{
Switch (SCORE/10)
{
Case 0:
Case 1:
Case 2:
Case 3:
Case 4:
Case 5:printf ("the Class of the classmate: e\n");
Case 6:printf ("the Class of the classmate: d\n");
Case 7:printf ("the Class of the classmate: c\n");
Case 8:printf ("the Class of the classmate: b\n");
Case 9:
Case 10:printf ("the Class of the classmate: a\n");
}
}
return 0;
}
If statement implementation: #include <stdio.h>
int main ()
{
int score;
printf ("Input student's score: \ n");
scanf ("%d", &score);
if (score<0 | | score>100) {
printf ("Data entered illegally!\n");
}
else{
if (score>90) {
printf ("The student's rank is: A");
}
if (score>=80 && score<=90) {
printf ("The student's rank is: B");
}
if (score>=70 && score<=79) {
printf ("The student's rank is: C");
}
if (score>=60 && score<=69) {
printf ("The student's rank is: D");
}
if (score>=0&&score<=59) {
printf ("The student's rank is: E");
}
}
return 0;
}