Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include bool grade ( c h a r correctAnswers [ ] , char studentAnswers [ ] ) { int correctCount = 0 ; int incorrectCount

#include
bool grade(char correctAnswers[], char studentAnswers[]){
int correctCount =0;
int incorrectCount =0;
for (inti=0; i<10; i++){
if(correctAnswers[i]== studentAnswers[i]){
correctCount++;
} else {
incorrectCount++;
}
}
if(correctCount8){
std::cout << "Congratulations!" <<std::endl;
std::cout << "You have passed the exam." <<std::endl;
std::cout << "Total number of correct answers: "<< correctCount <<std::endl;
std::cout << "Total number of incorrect answers: "<< incorrectCount <<std::endl;
return true;
} else {
std::cout << "Sorry, you have not passed the exam!" <<std::endl;
std::cout << "Total number of correct answers: "<< correctCount <<std::endl;
std::cout << "Total number of incorrect answers: "<< incorrectCount <<std::endl;
return false;
}
}
int main(){
char correctAnswers[]={'B','D','A','A','C','A','B','A','C','D'};
char studentAnswers[10];
int invalidInputCount =0;
for (inti=0; i<10; i++){
char answer;
do{
std::cout << "Enter answer #"<<i+1<<":
";
std::cin >> answer;
if(answer'A' && answer 'B' && answer 'C' && answer 'D'){
std::cout << "Error! Only A,B,C, and D are valid answers. Please try again." <<std::endl;
invalidInputCount++;
}
if(invalidInputCount>3){
std::cout << "GOODBYE" <<std::endl;
return 0;
}
} while (answer'A' && answer 'B' && answer 'C' && answer 'D');
studentAnswers[i]= answer;
}
grade(correctAnswers, studentAnswers);
return 0;
}

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

More Books

Students also viewed these Databases questions

Question

What do you see as your biggest strength/weakness?

Answered: 1 week ago

Question

2. When is the job to be completed?

Answered: 1 week ago

Question

What are the steps involved in the HR planning process?

Answered: 1 week ago