Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Program (grade Point Average) modify the program to calculate the grade-poin

ID: 3662291 • Letter: C

Question

C++ Program

(grade Point Average) modify the program to calculate the grade-point average, A grade of A is worth 4 points, B is what 3 point, and so on.

#include <iostream>
using namespace std;

int main()
{
   int grade; //Letter grade enter by user
   int aCount = 0;// Count of A grades
   int bCount = 0;// Count of B grades
   int cCount = 0;// Count of C grades
   int dCount = 0;// Count of D grades
   int fCount = 0;// Count of F grades

   cout << "Enter the letter grades." << endl
       << " Enter EOF character to end input." << endl;
   // loop until user types end -of-file key sequence
   while ((grade = cin.get()) != EOF)
   {
       // determine which grades was entered
       switch (grade)// switch statement nested in while
       {
       case 'A': // grade was uppercase A
       case 'a':// grade was lowercase a
           aCount++;// increment count
           break;// necessary to exit switch

       case 'B': // grade was uppercase B
       case 'b':// grade was lowercase b
           bCount++;// increment count
           break;// necessary to exit switch

       case 'C': // grade was uppercase C
       case 'c':// grade was lowercase c
           cCount++;// increment count
           break;// necessary to exit switch

       case 'D': // grade was uppercase D
       case 'd':// grade was lowercase d
           aCount++;// increment count
           break;// necessary to exit switch

       case 'F': // grade was uppercase F
       case 'f':// grade was lowercase f
           aCount++;// increment count
           break;// necessary to exit switch

       case ' ':// ignore newline
       case ' ': //tabs
       case ' ': //and space in input
           break;// exit switch

       default:// catch all other characters
           cout << " Incorrect Letter grade entered."
               << "Enter a new grade." << endl;
           break;// optional will exit switch anyway

       }
   }
   // output summary of result
   cout << " Number of student who received letter grades."
       << " A: " << aCount // display number of A grades
       << " B: " << bCount // display number of B grades
       << " C: " << cCount // display number of C grades
       << " D: " << dCount // display number of D grades
       << " F: " << fCount // display number of F grades
       << endl;

} // end main

Explanation / Answer

#include <iostream>
using namespace std;
int main()
{
int grade; //Letter grade enter by user
int aCount = 0;// Count of A grades
int bCount = 0;// Count of B grades
int cCount = 0;// Count of C grades
int dCount = 0;// Count of D grades
int fCount = 0;// Count of F grades
cout<<"Enter the letter grades."<<endl;
cout<<"Enter EOF(i.e 'q') character to end input."<< endl;
// loop until user types end -of-file key sequence
while(1)
{
   cout<<"Enter the letter grades."<<endl;
       cout<<"Enter EOF(i.e 'q') character to end input."<< endl;
       cin>>grade;
// determine which grades was entered
switch (grade)// switch statement nested in while
{
case 'A': // grade was uppercase A
case 'a':// grade was lowercase a
aCount++;// increment count
break;// necessary to exit switch
case 'B': // grade was uppercase B
case 'b':// grade was lowercase b
bCount++;// increment count
break;// necessary to exit switch
case 'C': // grade was uppercase C
case 'c':// grade was lowercase c
cCount++;// increment count
break;// necessary to exit switch
case 'D': // grade was uppercase D
case 'd':// grade was lowercase d
aCount++;// increment count
break;// necessary to exit switch
case 'F': // grade was uppercase F
case 'f':// grade was laowercase f
aCount++;// increment count
break;// necessary to exit switch
case 'q':// quit newline
case 'Q': //tabs
           break;
}
}
// output summary of result
cout << " Number of student who received letter grades.";
cout << " A: " << aCount<<endl; // display number of A grades
cout << " B: " << bCount<<endl; // display number of B grades
cout << " C: " << cCount<<endl; // display number of C grades
cout << " D: " << dCount<<endl; // display number of D grades
cout << " F: " << fCount<<endl; // display number of F grades
cout << endl;
} // end main

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote