
Untitled
By: a guest on
Aug 20th, 2012 | syntax:
C++ | size: 0.84 KB | hits: 17 | expires: Never
//Write a program that allows the user to enter the grade scored in a programming class (0-100).
//If the user scored a 100 then notify the user that they got a perfect score.
//★ Modify the program so that if the user scored a 90-100 it informs the user that they scored an A
//★★ Modify the program so that it will notify the user of their letter grade
//0-59 F 60-69 D 70-79 C 80-89 B 90-100 A
#include <iostream>
using namespace std;
int main(){
int x;
cout << "Enter your grade: \n";
cin >> x;
switch(x)
{
case x<=59: cout << "F\n";
break;
case 59<x<=69: cout << "D\n";
break;
case 69<x<=79: cout << "C\n";
break;
case 79<x<=89: cout << "B\n";
break;
case 89<x<=99: cout << "A\n";
break;
case x==100: cout << "A, Perfect Score!\n";
break;
default: cout << "Please enter a valid grade";
break;
}
cin.get();
}