Friday, June 4, 2021

Average Grade Solver Using While Loop in C++

 Machine Problem

Write a program that will ask the user to give a grade and then the program will compute the average grade using while loop statement in C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.








Program Listing

/* average_grade_while_loop.cpp
   Jake Rodriguez Pomperada,MAED-IT,MIT
   www.jakerpomperada.com www.jakerpomperada.blogspot.com
   jakerpomperada@gmail.com
   Bacolod City, Negros Occidental Philippines
*/

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
int NumGrades=0;
double grades=0.00;
double total=0.00,GradeAv=0.00;
cout <<"\n\n";
    cout <<"\tAverage Grade Solver Using While Loop in C++";
    cout <<"\n\n";
     while(NumGrades != -1)
{
cout << "\tEnter the Grade No. " << (NumGrades+1)
<< ".  (Press -1 To Stop ) : ";
cin >> grades;
total += grades;
if (grades == -1) {
GradeAv = ceil((total / NumGrades));
cout << "\n\n\tThe average of Grade is " << 
     GradeAv<< ".";
break;
}
NumGrades++;
     }
      cout <<"\n\n";
  cout <<"\tEnd of Program";
  cout <<"\n";
}

No comments:

Post a Comment