I'm quite confused with this question. Can anyone enlighten me?
The question is:
Write a function that converts a char letter grade into its numerical equivalent. Use the grading system below. A=4.0 B=3.0 C=2.0 D=1.0 F=0.0
To receive full credit your answer must use a switch statement. In case when the function receives a character that is not A,B,C,D,F, return value 0.0. The prototype is below:
double gradeNum(char grade)
{ //your code here
//This is my coding
#include<iomanip>
#include<iostream>
#include<string>
using namespace std;
double gradeNum(char grade);
int main ()
{
char grade;
cout<<"Please enter your grade;"<<endl;
cin>>grade;
double output=gradeNum(grade);
cout<<output;
return 0;
}
double gradeNum(char grade){
switch (grade){
case 'A':
return 4.0;
break;
case 'B':
return 3.0;
break;
case 'C':
return 2.0;
break;
case 'D':
return 1.0;
break;
case 'F':
return 0.0;
break;
default:
return 0.0;
break;
}
}