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."
#include <iostream>
using namespace std;
int main() {
int num_pass=0, num_fail=0;
int result;
for (int i=0; i<10; i++) {
cout << "Enter result ";
cin >> result;
if (result == 1) {
num_pass++;
}
else if (result == 2) {
num_fail++;
}
}
cout << "The number of students who passed is " << num_pass << endl;
cout << "The number of students who failed is " << num_fail << endl;
if (num_pass > 8) {
cout << "Raise tution." << endl;
}
return 0;
}
Comments
Leave a comment