Please i need it ASAP i will give you a thumbs up Thank you Q4: Re-write the code using do-while and for loop. // Class average program with sentinel-controlled repetition. #include using std::cout;...







Please i need it ASAP i will give you a thumbs up Thank you



Q4: Re-write the code using do-while and for loop.


// Class average program with sentinel-controlled repetition.

#include

using std::cout;

using std::cin;

using std::endl;

using std::fixed;

#include

using std::setprecision;

int main()

{

int total;

int gradeCounter;

int grade;

double average;

total = 0;

gradeCounter = 0;

cout < "enter="" grade,="" -1="" to="" end:="">

cin >> grade;

while ( grade != -1 ) {

total = total + grade;

gradeCounter = gradeCounter + 1;

cout < "enter="" grade,="" -1="" to="" end:="">

cin >> grade;

}

if ( gradeCounter != 0 ) {

average = static_cast< double="">( total ) / gradeCounter;

cout < "class="" average="" is="" "="">< setprecision(="" 2="">

< fixed="">< average=""><>

} // end if part of if/else

else

cout < "no="" grades="" were="" entered"=""><>









return 0;

} // end function main






Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here