Question
You have been approached by a University to create a C# program to calculate the averages for students in three different departments: Computer Science, Mathematics,
You have been approached by a University to create a C# program to calculate the averages for students in three different departments: Computer Science, Mathematics, and Business Administration. Using a sentinel value while loop (not a do-while loop), you are to process mark data until the user indicates that you should stop (there could be 0 or more data values). For each student processed, the program must first input the department code (char deptCode): C or c for Computer Science, M or m for Mathematics, and B or b for Business Administration, followed by a mark value (double markVal). The program should stop accepting input when the user enters a Q or q for the department code to signal the quit (sentinel value). Your main loop should be conditioned on the fact that the user has not signaled quit. It might look something like: while(char.ToUpper(deptCode) != Q) This implies that, like any sentinel value loop, you must seed the loop (input a department code) PRIOR to entering the loop. Inside the loop, the mark data is entered, processed and another department code entered. Once the main loop terminates (user enters a Q or q), the averages for the 3 departments are to be computed and printed out. Be sure to print an error message if the user enters an invalid department code or an invalid mark (less than 0 or greater than 100). Also, take care as to not divide by 0! Here is a sample output of what you might see: Enter a department code: C or c for Computer Science,M or m for Math, B or b for Business Admin, or enter Q or q to quit => C Enter the mark (>= 0 or <= 100) => 90 Enter a department code: C or c for Computer Science,M or m for Math, B or b for Business Admin, or enter Q or q to quit => m Enter the mark (>= 0 or <= 100) => 85.2 Enter a department code: C or c for Computer Science,M or m for Math, B or b for Business Admin, or enter Q or q to quit => B Enter the mark (>= 0 or <= 100) => 70 Enter a department code: C or c for Computer Science,M or m for Math, B or b for Business Admin, or enter Q or q to quit => b Enter the mark (>= 0 or <= 100) => 60.0 Enter a department code: C or c for Computer Science,M or m for Math, B or b for Business Admin, or enter Q or q to quit => Q The average for Computer Science students is 90.0 The average for Mathematics students is 85.2 The average for Business Administration students is 65.0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started