Question

In: Computer Science

Java Script. Develop a program that will determine the slugging percentages and batting average of several...

Java Script.

Develop a program that will determine the slugging percentages and batting average of several New York Yankees from the 2006 season. Slugging percentage is calculated by dividing the total number of bases by the number of at bats. The number of bases would be one for every single, two for every double, three for every triple, and four for every home run. The batting average is calculated by dividing the total number of hits by the number of at bats. You do not know the number of players in advance, but for each player you know their number of singles, doubles, triples, home runs, total number of at bats, and the player's name (use the proper type and method for each variable).

You will use a while sentinel loop on the 1st item to input. If it is not the sentinel, go into the while sentinel loop and separately input the rest of the input items (be careful of the enter in the input memory buffer for the player name). You will then calculate the total bases and the slugging percentage. You will then calculate the batting average. You will then print out the player's name, the labeled slugging percentage for that player to three decimal places, and the labeled batting average for that player to three decimal places. Use separate output statements. Print a blank line between players. This loop will repeat for as many players as you need.

Run your program with the following players and sentinel value (to show the sentinel value worked):

Create a java script. Modify your program that determined the slugging percentages and batting average of several New York Yankees from the 2006 season. The user now knows in advance the number of players to process. You will ask the user to input the number of players and input that value into a variable. You will use a while loop to check their input. While their input is less than zero or more than twenty, you will ask them to re-input the number of players, since the number of players has to be from zero to twenty. Use proper form for the while loop. Since we now know the number of players, use a for loop to count up to their number. Inside the loop, input all the data, calculate the batting average and slugging percentages, and print the name, batting average, and slugging percentage as in the while sentinel loop. Use proper form for the for loop. Make sure everything from part one is working properly. Slugging percentage is calculated by dividing the total number of bases by the number of at bats. The number of bases would be one for every single, two for every double, three for every triple, and four for every home run. The batting average is calculated by dividing the total number of hits by the number of at bats. You do not know the number of players in advance, but for each player you know their number of singles, doubles, triples, home runs, total number of at bats, and the player's name (use the proper type and method for each variable). Then use a for loop with a counter. While the counter is less than or equal to the number of players, go into the for loop and separately input the items (be careful of the enter in the input memory buffer for the player name). You will then calculate the total bases and the slugging percentage. You will then calculate the batting average. You will then print out the player's name, the labeled slugging percentage for that player to three decimal places, and the labeled batting average for that player to three decimal places. Use separate output statements. Print a blank line between players. This loop will repeat for as many players as the user asked for. Run your program with the following input and players: Enter number of players (0 – 20): 25 Invalid number of players. Enter number of players (0 – 20): -1 Invalid number of players. Enter number of players (0 – 20): 3 Singles: 158 Doubles: 39 Triples: 3 Home Runs: 14 At Bats: 623 Player: Derek Jeter Singles: 51 Doubles: 25 Triples: 0 Home Runs: 37 At Bats: 446 Player: Jason Giambi Singles: 104 Doubles: 26 Triples: 1 Home Runs: 35 At Bats: 572 Player: Alex Rodriguez

Solutions

Expert Solution


Related Solutions

SLUGGING PERCENTAGES & BATTING AVERAGES - SENTINEL LOOP Develop a program in JAVA that will determine...
SLUGGING PERCENTAGES & BATTING AVERAGES - SENTINEL LOOP Develop a program in JAVA that will determine the slugging percentages and batting average of several New York Yankees from the 2006 season.  Slugging percentage is calculated by dividing the total number of bases by the number of at bats.  The number of bases would be one for every single, two for every double, three for every triple, and four for every home run.  The batting average is calculated by dividing the total number of...
In java P4.6 Following Section 4.9 develop a program that reads text and displays the average...
In java P4.6 Following Section 4.9 develop a program that reads text and displays the average number of words in each sentence. Assume words are separated by spaces, and a sentence ends when a word ends in a period. Start small and just print the first word. Then print the first two words. Then print all words in the first sentence. Then print the number of words in the first sentence. Then print the number of words in the first...
java script coding to create a math test program with 5 questions.
java script coding to create a math test program with 5 questions.
Statistics are widely used in Major League Baseball. Does a baseball player's batting average (AVG) determine...
Statistics are widely used in Major League Baseball. Does a baseball player's batting average (AVG) determine their salary? The following is a chart of 25 baseball players' statistics from 2016. Let the explanatory variable x = AVG and the response variable y = Salary. DATA: Professional Baseball League Player RBI HR AVG Salary (in millions) Jacoby Ellsbury 56 9 0.263 21.143 Joey Votto 97 29 0.326 20 Prince Fielder 44 8 0.212 18 Matt Wieters 66 17 0.243 15.8 Jason...
JAVA script! You will write a program that will input the nationalities of your favorite types...
JAVA script! You will write a program that will input the nationalities of your favorite types of food, examples, and prices of some of your favorite food. You will save a type of food, two examples of that type of food, the price of each of those two examples, and a total price of both together. You must input your own types, examples, and prices, but check a sample run below. You must use the concepts and statements that we...
Java Proect Project Outcomes Develop a Java program that: • creates a user designed class •...
Java Proect Project Outcomes Develop a Java program that: • creates a user designed class • uses proper design techniques including reading UML Class Diagrams • reads input from the keyboard using a Scanner Object and its methods • uses selection (if and if else) statements • uses iteration (while, do while or for) statements • uses String comparison methods. • follows standard acceptable programming practices. • handles integer overflow errors Prep Readings: Zybooks chapter 1 - 6 1. General...
URGENT JAVA Develop a Java computer program to simulate access control to a system network. The...
URGENT JAVA Develop a Java computer program to simulate access control to a system network. The username and password authentication mechanism is used as an access control mechanism in this project. The program needs to authenticate the user with their username and hashed password stored in Access Manager User (AMU) file. To create an Access Manager User file, you need to develop a java program that takes username and password as input and then generates a file containing the username,...
In 2007, the batting average of MLB players have μ=0.283μ=0.283 and σ=0.027σ=0.027. In 2013, the batting...
In 2007, the batting average of MLB players have μ=0.283μ=0.283 and σ=0.027σ=0.027. In 2013, the batting averages have μ=0.271μ=0.271 and σ=0.029σ=0.029. In 2007, Ronnie Belliard had a batting average of 0.2900.290. In 2013, Manny Machado had a batting average of 0.2830.283. Which of these players performed better, in relation to the year they played? a. Manny Machado performed better than Ronnie Belliard since the z-score of Machado’s batting average is higher than that of Belliard’s batting average. b. Ronnie Belliard...
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java...
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java program that will solve the following problem. The program uses one and two-dimensional arrays to accomplish the tasks specified below. The menu is shown below. Please build a control panel as follows: (Note: the first letter is shown as bold for emphasis and you do not have to make them bold in your program.) Help SetParams FillArray DisplayResults Quit Upon program execution, the screen...
Develop a matlab script file to calculate the practical single phase transformer parameters. The program should...
Develop a matlab script file to calculate the practical single phase transformer parameters. The program should ask the user to provide the following individually: S_rated V1_rated V2_rated With secondary shorted P1 V1 With primary open P2 I2 The program should calculate Req Xeq Zeq Gc Ym Bm Make sure your code will pronmpt a message like: “Enter the real power at the primary winding when the secondary winding is shorted, P1=). Do the same for all parameters S, V1_rated, V2_rated,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT