• Home
  • Blog
  • CISS 110 Rutgers University Newark Create a Java Code Computer Programming Task

CISS 110 Rutgers University Newark Create a Java Code Computer Programming Task

0 comments

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):

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

Singles: -1

Document your program with at least name, exercise number, and at least 4 – 5 lines explaining what the program does, including the looping. Execute your program with the above four inputs in one run. Save (or Copy and Paste) the Console running of your program into a plain output .txt text file. Submit your .java source code main program and the output .txt saved.

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}