Homework You will write a method that will calculate the earned run average (ERA) of a baseball pitcher for one month of starts during the season. The ERA is calculated by dividing the number of...

Homework You will write a method that will calculate the earned run average (ERA) of a baseball pitcher for one month of starts during the season. The ERA is calculated by dividing the number of earned runs the pitcher allowed by the number of inning pitched and then multiplying this value by 9. Instructions: • Create a project and a class named ERA in BlueJ. NOTE: Use that name exactly. • Add an import java.util.*; statement before the class and create a main program inside the class. • In main, create a Scanner object that will be used for input. Prompt the user to enter the name of the pitcher and store the name in a String variable named name. Prompt the user to enter the number of starts the pitcher had in the month and store the number of starts in an integer variable named starts. If the number of starts is less than or equal to 0, display a message saying there is no data for the pitcher. Include the pitcher's name in the message. Otherwise (else), use a for loop to do the following for each start: o Prompt the user to enter the number of earned runs allowed and store this number in an integer variable named runs. o Prompt the user to enter the number of inning pitched and store this value in a double variable named innings. (NOTE: If a pitcher pitched 6 and 2/3 innings, meaning 6 full innings pitched and got 2 batters out in the 7th, enter 6.2). . When the loop is finished, calculate the ERA by dividing the number of earned runs by the number of innings pitched and multiplying by 9. • Sample input: O Pitcher: Clayton Kershaw o Had 4 starts o Allowed 2 runs while pitching 6 2/3 (6.2) innings in Start 1 o Allowed 3 runs while pitching 5 1/3 (5.1) innings in Start 2 o Allowed 1 run while pitching 7 (7.0) innings in Start 3 O Allowed 2 runs while pitching 7 2/3 (7.2) innings in Start 4 Display the data like this: o Pitcher: Clayton Kershaw o Earned Runs: 8 o Innings Pitched: 25.5 O ERA: 2.82 NOTE: Innings Pitched should be rounded to 1 decimal place. ERA should be rounded to 2 decimal places.
May 25, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here