0
An example of a program to determine the point equivalent to the grade using switch-case statement .....
A=12points,B=9points,C=6points,D=3points,E=0points
2 Answers
+ 8
char grade;
int points;
// input grade
switch (grade)
{
case 'A': points = 12; break;
case 'B': points = 9; break;
// and so on lol
}
+ 1
#include <iostream>
using namespace std;
int main (void){
int points;
cout<<"Enter your points: ";
cin>>points;
if (points < 0 || points > 12){
cerr<<"Out of range (0-12)";
return -1;
}
switch (points){
case 10:
case 11:
case 12:
cout<<"A";
break;
case 7:
case 8:
case 9:
cout<<"B";
break;
case 4:
case 5:
case 6:
cout<<"C";
break;
case 1:
case 2:
case 3:
cout<<"D";
break;
default:
cout<<"E";
}
return 0;
}