Question
//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?
#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; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started