Gold University of Minnesota M. Skip to main content.University of Minnesota. Home page.
 
 
 

What's inside.

Ta Email

Download Compiler

Final Project

Lab Notes

Office Hours

Schedule

Syllabus

Announcements

Check Grades

 

CSci 1113 Home

 
 

Printer-friendly version

 
Grade Assignment Program Using a Multiway if-else Statement

// Grade Assignment
#include <iostream>
using namespace std;

int main()
{
   int points;
   char grade;

   cout << "Enter a test score: ";
   cin >> points;

   if (points >= 90)
     grade = 'A';

   else if (points >= 80)
     grade = 'B';

   else if (points >= 70)
     grade = 'C';

   else if (points >= 60)
     grade = 'D';

   else
     grade = 'F';

   cout << "The grade is " << grade << endl;
}

% g++ grades.cpp
% a.out
Enter a test score: 88
The grade is B
% a.out
Enter a test score: 67
The grade is D

 
The University of Minnesota is an equal opportunity educator and employer.
CSci 1113: C++ Programming