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
#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;
}
Comments
Leave a comment