Answer to Question #333747 in C++ for jane

Question #333747

Wite a C++ function. A college offers a course that prepares students for the state licensing exam for real estate brokers.

Last year, ten of the students who completed this course took the exam. The college wants to know

how well its students did on the exam. You have been asked to write a program to summarize the

results. You have been given a list of these 10 students. Next to each name is written a 1 if the

student passed the exam or a 2 if the student failed.

Your program should analyze the results of the exam as follows:

Input each test result (i.e., a 1 or a 2). Display the prompting message "Enter result" each time the

program requests another test result.

Count the number of test results of each type.

Display a summary of the test results indicating the number of students who passed and the

number who failed.

If more than eight students passed the exam, print the message "Raise tuition."


1
Expert's answer
2022-04-28T13:22:31-0400
#include <iostream>
#include <string>>
using namespace std;

int main() {
  string student[10]={"Robert", "David", "Charles", "Anna", "Daniel", "John", "Liss",
              "Terry", "Dylan", "Jesse"};
  int result[10];
  int i;
   
  for(i=0; i<10;i++){
          cout<<"Enter result (1/2). "<<student[i]<<": ";
          cin>>result[i];   
        while(result[i]!=1 && result[i]!=2){
              cout<<"Result musy be 1 or 2: "<<student[i]<<": ";
              cin>>result[i];  
          }
     }
    int res1=0, res2=0;
     for(i=0; i<10;i++) {
         if(result[i]==1    )
            res1++;
        else
            res2++;
     }
     cout<<endl<<"___________________________"<<endl;
      cout<<"Summary of the test results: "    <<endl<<
      "The number of students who passed: "<<res1<<endl<<
      "The number who failed: "<<res2<<endl;
      if(res1>8)
          cout<<"Raise tuition"<<endl;
 
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS