Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//Using the code below (and the modifications you provide) how do i get an output of Invalid input: Please re-enter an interger number. when typing

//Using the code below (and the modifications you provide) how do i get an output of "Invalid input: Please re-enter an interger number." when typing ABC or ? as inputs when entering students?image text in transcribed

#include

#include

using namespace std;

int getNumberOfStudents(){

double n;

while(true){

cout

cout

cin >> n;

cin.clear();

cin.ignore(100,' ');

if ( n != int(n) ){

cout

}

else if (int(n)

cout

cout

cout

}

else{

return n;

}}}

void initialize(int &countGradeA, int &countGradeB, int &countGradeC, int &countGradeD, int &countGradeF){

countGradeA = 0;

countGradeB = 0;

countGradeC = 0;

countGradeD = 0;

countGradeF = 0;

}

void classifyGrade(double grade, int &countGradeA, int &countGradeB, int &countGradeC, int &countGradeD, int &countGradeF){

if (grade >= 90)

countGradeA++;

else if (grade >= 80)

countGradeB++;

else if (grade >= 70)

countGradeC++;

else if (grade >= 60)

countGradeD++;

else if (grade

countGradeF++;

}

void printResults(int countGradeA, int countGradeB, int countGradeC, int countGradeD, int countGradeF){

cout

cout

cout

cout

cout

cout

cout

cout

cout

}

void getNumberGrade(int& grade)

{

while(true)

{

cout

cin >> grade;

cin.clear();

cin.ignore(100,' ');

if ( grade != int (grade) || grade = 101 ){

{

cout

}

}

else

break;

}

}

int main(){

int grade;

int countGradeA, countGradeB, countGradeC, countGradeD, countGradeF;

initialize(countGradeA, countGradeB, countGradeC, countGradeD, countGradeF);

double n = getNumberOfStudents();

for (int i = 0; i

getNumberGrade(grade);

classifyGrade(grade,countGradeA, countGradeB, countGradeC, countGradeD, countGradeF);

}

printResults(countGradeA, countGradeB, countGradeC, countGradeD, countGradeF);

return 0;

}

E:\ET575\Projects\gradingfunctions.exe GRADE STATISTICS Please enter number of students: ABC Invalid input. Please re-enter an integer number. Please enter number of students:? Invalid input. Please re-enter an integer number. Please enter number of students: 1 Invalid input. Please re-enter. Please enter number of students: 1.1 Invalid input. Please re-enter an integer number. Please enter number of students: 3 Please enter an integer grade between 0 and 100: ABC Invalid input. Please re-enter an integer number* Please enter an integer grade between and 10: ? Invalid input. Please re-enter an integer number.. Please enter an integer grade between and 10:1 Invalid grade* Please re-enter. Please enter an integer grade between 0 and 100: 111 Invalid grade? Please re-enter . Please enter an integer grade between 0 and 100: 1.1 Invalid input. Please we-enter an integer number. Please enter an integer gxade between and 100: 77 Please enter an integer grade between 0 and 100:88 Please enter an integer grade between b and 100: 99 PROGRAM ENDING. GOOD BYE<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Eric Redmond ,Jim Wilson

1st Edition

1934356921, 978-1934356920

More Books

Students also viewed these Databases questions