demo-switch-grades - { case 'A': cout...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Demo of switch // Letter grade --> grade range program #include <iostream.h> // for cin, cout, endl #include <ctype.h> // for toupper int main() { char letterGrade; // input letter grade cout << "Enter a letter grade: "; cin >> letterGrade; letterGrade = toupper(letterGrade); // make it uppercase for processing switch(letterGrade) // print out grade range
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { case 'A': cout &lt;&lt; &quot;Grade is between 90 and 100&quot;; break; case 'B': cout &lt;&lt; &quot;Grade is between 80 and 89&quot;; break; case 'C': cout &lt;&lt; &quot;Grade is between 70 and 79&quot;; break; case 'D': cout &lt;&lt; &quot;Grade is between 60 and 69&quot;; break; case 'F': cout &lt;&lt; &quot;Grade is between 0 and 59&quot;; break; default: cout &lt;&lt; &quot;Grade entered is not a valid letter grade&quot;; } cout &lt;&lt; endl; return 0; }...
View Full Document

This document was uploaded on 02/10/2011.

Ask a homework question - tutors are online