Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using if-end and while-end statements, perform the following: Prompt the user to

ID: 2072998 • Letter: U

Question

Using if-end and while-end statements, perform the following: Prompt the user to enter numerical grades, one grade at a time (i.e. do not use vectors). Any number of grades can be entered, however, each grade must be non-negative and no larger than 100. Otherwise, the grade is considered invalid and the user should be prompted to re-enter the grade. A grade of 999 indicates the user has finished entering numerical grades. Compute the number of grades in each grade range using the standard grading policy: A [90 - 100], B [80 - 90), C [70 - 80), D [60 - 70), F [0 - 60). Compute the minimum grade, maximum grade, and average grade. You are NOT allowed to use built-in functions min(), max(), sum(), or mean(). Using multiple instances of the built-in fprintf() function, display the following items in the Command Window: the number of valid grades entered by the user formatted as an integer (always display) the number of valid grades belonging to each grade range, each formatted as an integer (always display) the minimum grade, maximum grade, and average grade, each as a fixed-point real number showing a maximum of 3 digits beyond the decimal point (display when at least one valid grade is entered) the overall letter grade according on the average formatted as a character. (display when at least one valid grade is entered).

Explanation / Answer

grade=0; total=0; counter =-1; disp('When done entering grades enter "-1"'); prompt = ('Input another Grade: '); i=1; while (grade ~= -1) total = total + grade; counter = counter +1; grade = input(prompt); grade1(i) = grade; i=i+1; end Average = (total/counter); disp('Average = '); disp(Average); disp('Min = ') MIN = min(grade1(1,:)); disp(MIN) disp('Max = ') MAX = max(grade1); disp(MAX) k=1; allGrades = []; while true grade = input(prompt); if grade < 0 break; end allGrades(k) = grade; k=k+1; end
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote