Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program for Java Write a program that uses control structures to calculate the average test score for any given number of students and any given

Program for Java

Write a program that uses control structures to calculate the average test score for any given number of students and any given number of tests, both determined by the user using input statements. Begin the program with a while loop that runs only when the number of students does not equal 0. Within the while loop, ensure the program iterates through each student while performing the following tasks:

1) Use an accumulator to hold the sum of the students test scores. Make sure the accumulator is placed in a spot to ensure it resets to 0 before looping to the next students test scores.

2) Iterate through the number of tests given through user input, adding each test score the student received to the accumulator.

3) Once all scores for a single student are totaled, determine the average score the student received (totalScore/numTests).

4) Output the average test score and use a conditional statement to output a string stating whether the student passed or failed based on the final average. A failing grade will be any number below 60. Assume each test is graded out of 100 points. Make sure the average is formatted as a decimal with 2 decimal places.

5) Once the given number of students has been looped through, ask the user again for the number of students to restart the loop, with the number 0 exiting the program.

Here is an example of what your output should reflect:

Enter number of students:

2

Enter number of tests:

3

Enter grade for student 0

100

Enter grade for student 0

90

Enter grade for student 0

80

Final average for student 0: 90

Pass

Enter grade for student 1

55

Enter grade for student 1

45

Enter grade for student 1

89

Final average for student 1: 63

Pass

Enter new number of students or press 0 to exit:

0

Process finished with exit code 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago