Answer to Question #335663 in C++ for fhnai

Question #335663

NOTE: Not by using arrays.

write a C++ function. in which 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." write code in function not by using arrays



1
Expert's answer
2022-04-30T05:39:39-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