Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, expand (again) on the Shooting Percentage calculator from programs 2 and 3. This time the program will do better error checking than

For this assignment, expand (again) on the Shooting Percentage calculator from programs 2 and 3. This time the program will do better error checking than in program 3 and it will have the ability to calculate the Shooting Percentage through multiple games.

Processing

As noted above, there are two changes that need to be made for this program. The first is to do better error checking for both the number of goals scored and the number of shot attempts than what was used in program 3. Instead of using a decision statement, change the error checking so that it uses one of the three loops that has been discussed in lecture. The choice of loop is up to you unless otherwise specified by your instructor.

The use of a loop for the error checking rather than a decision statement will allow us to make sure that user of the program really does "get it right" when they are entering the input rather than we, as programmers, assuming that they will "get it right."

The second change that needs to made for this program is to make it so that it can calculate the Shooting Percentage through multiple games. To do this, three things will need to be added. The first is that the code that has already been written should be placed inside of a loop that executes as long as there is data to be entered.

To determine if there is more data to be entered, the user should be asked, "Is there more data?". An answer of "y" indicates there is more data. Anything else, including "Y", indicates there is no more data. (Notice the double quotes around the "y" - this means that a string variable should be used for this value.)

The second thing to be added (it must go inside of the loop) is to make a small change to the formula to calculate the shooting percentage. The values that the user is entering are the number of goals and shot attempts for ONE game. The calculation for this program should be for MULTIPLE games. This means that the program will need to keep track of the total number of goals that have been scored and the total number of shots that have been attempted. The two totals will be what is used to calculate the shooting percentage.

As with programs 2 and 3, display the shooting percentage. However, the display should include the number of games that have been played. This is the third thing to be added (again, inside of the loop).

Once the user has indicated that there is no more data, the program should end.

(below is the link to the previous assignment)

https://www.chegg.com/homework-help/questions-and-answers/assignment-expand-shooting-percentage-calculator-program-2-original-version-program-didn-t-q26557781?trackid=1986b8da&strackid=4025642e&ii=1

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

More Books

Students also viewed these Databases questions