Sunday, August 2, 2009

A c++ code that generate a student grade using switch method?

#include %26lt;iostream%26gt;


using namespace std;





int main()


{


char test;





cout %26lt;%26lt; "enter grade";


cin %26gt;%26gt; grade;








switch ( grade ) {





case 50 :





cout %26lt;%26lt; "You Failed";





case 60 :





cout %26lt;%26lt; "You Just made it";





case 70:





cout %26lt;%26lt; "You passed";





case 80:





cout %26lt;%26lt; "good job";





case 90:


cout %26lt;%26lt; "wow a 90";





case 100:


cout %26lt;%26lt; "way to go you got a 100";





default :


// Process for all other cases.








}





}





you should be able to work off this if i am understanding your question correctly

A c++ code that generate a student grade using switch method?
Most grading systems are like this: 65 and lower: F, 70-75: D, 75-80-C, etc.... Notice it's all 5 units apart, and the grades are from 0 to 100. So take the grade and divide it by 5. Now your result is between 0 and 20. 20 is an A+, 19 is an A, 18 is a B+, etc... I think you can see how this could easily be a switch statement.


No comments:

Post a Comment