Output: Look at the questions and choices on page 999 of your textbook. Enter the UPPERCASE letter of your choice for each question when prompted below. Enter your response for Question 1: [user types: a] Enter your response for Question 2: [user types: D] Enter your response for Question 3: [user types: B] Enter your response for Question 4: [user types: b] Enter your response for Question 5: [user types: A] You answered 4 out of 5 questions correctly

Respuesta :

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

char input(){

   char student;    cin>>student;

   return student;

}

int compare(char student, char teacher){

   int score = 0;

   if(tolower(student) == tolower(teacher)){            score++;

       }

       return score;

}

int main(){

   char teacher[5] = {'C', 'D', 'B', 'B', 'A'};    

   int score = 0;

   for (int i = 0;i<5;i++){

       cout<<"Question "<<i+1<<": ";

       char student = input();

       score+= compare(student,teacher[i]);

   }

   cout<<"You answered "<<score<<" out of 5 questions correctly";

   return 0;

}

Explanation:

Given

See attachment (1) for complete question

See attachment (2) for complete source file where comment are used to explain

Ver imagen MrRoyal