C++ cin Adds grades and determines whether you earned an A.

Description

C++ cin Adds grades and determines whether you earned an A.

#include <iostream>
using namespace std;
include <iomanip.h>
int main()// ww w . j  a  va2s  .  c  o  m
{
   float total_grade=0.0;
   float grade;             // Holds individual grades.
   do
   {
      cout << "What is your grade? (-1 to end) ";
      cin >> grade;
      if (grade >= 0.0)
      {
         total_grade += grade;
      }        // Add to total.
   } while (grade >= 0.0);     // Quit when -1 entered.

   cout << "\n\nYou made a total of " << setprecision(1) << total_grade << " points\n";
   if (total_grade >= 450.00)
   {
      cout << "** You made an A!!";
   }
   return 0;
}



PreviousNext

Related