Starting Out with C++ (9th Edition) Ch 8, PC15. Section 2: What are the 2 cout s
ID: 3853340 • Letter: S
Question
Starting Out with C++ (9th Edition) Ch 8, PC15. Section 2: What are the 2 cout statements after the last if statement?
Unable to paste.
void TestGrader::grade(char testAns[])
{
int correct=0;
for(int i=0; i<20; i++)
{
if(testAns[i]==answers[i] || answers[i]==' ')
{
correct++;
}
}
// check answers
if(correct>=15)
{
cout<<" The applicant passed the exam. ";
}
else
cout<<" The applicant failed the exam. ";
cout<<"Number of right answers: " << 20-correct;
cout<< List of the question numbers for all incorrect answers: ";
for(int i=0; i<20; i++)
{
if(testAns[i]!=answers[i] && answers[i]!=' ')
{
cout<<
}
}
cout<<
return;
}
Explanation / Answer
You need to display the number of wrong answers as well. Here is the modified code for the same. Please rate the answer if it helped. Thank you.
void TestGrader::grade(char testAns[])
{
int correct=0;
for(int i=0; i<20; i++)
{
if(testAns[i]==answers[i] || answers[i]==' ')
{
correct++;
}
}
// check answers
if(correct>=15)
{
cout<<" The applicant passed the exam. ";
}
else
cout<<" The applicant failed the exam. ";
cout<<"Number of right answers: " << correct;
cout<<"Number of wrong answers: " << (20 - correct);
cout<< List of the question numbers for all incorrect answers: " ;
for(int i=0; i<20; i++)
{
if(testAns[i]!=answers[i] && answers[i]!=' ')
{
cout<< (i+1) << " ";
}
}
cout<< " ";
return;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.