Question: write the code in c++ Read data that controls the loop (the gender) while (more data) { Read additional data and process Read data (the
write the code in c++
Read data that controls the loop (the gender) while (more data) { Read additional data and process Read data (the gender) } The admissions office of your local university wants to know how well male and female students perform in certain courses. You will enter the students gender as a CHAR (m or f") and gpa. Input continues until the user enters x as the gender. You program will calculate the average gpa for EACH female students and for male students separately. That means you need a separate counter and accumulator for EACH gender. Each time a gender and gpa is entered, you will need to update the appropriate accumulator and counter. A swtich could be very useful here! When all input is complete, calculate and display the average gpa for female students and the average gpa for male students (with 1 decimal place). If there are no students of a particular gender then ONLY output "No male students" or "No female students" (instead of an average). Your program should work for upper or lower case, if the user inputs M, m, F, or f as gender. For this problem you can assume no invalid data.
Sample Output (Test Case 1) Enter gender or x to quit: f Enter gpa: 2.5 Enter gender or x to quit: f Enter gpa: 3.2 Enter gender or x to quit: m Enter gpa: 2.8 Enter gender or x to quit: f Enter gpa: 3.0 Enter gender or x to quit: m Enter gpa: 2.2 Enter gender or x to quit: x Average Male GPA: 2.5 Average Female GPA : 2.9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
