Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Written Escola Methodist Hotepad file Edit Format View Help Create a public method that will return the total bases for a baseball player. To calculate

image text in transcribed
image text in transcribed
Written Escola Methodist Hotepad file Edit Format View Help Create a public method that will return the total bases for a baseball player. To calculate total bases we start with 4 values - the number of singles, doubles, triples, and home runs an individual player has. We will define 4 parameters, all integer values, to represent each. In the body we will take the 4 values and multiply each by their respective base value, a single is worth 1 base, a double worth 2 bases, a triple worth 3 bases, a home run worth 4 bases. After multiplying each parameter by its base value, we add all four values together for the total number of bases. For example, if a player has 10 singles, 4 doubles, 1 triple, and 1 home run - we would use this calculation: (19. 1) + (4 2) + (1 3) + (1 - 4) - 25 total bases. If a player has 25 singles, 10 doubles, 2 triples, 5 home runs - 25+ (102) + (2 + 3) + (5 * 4) - 71 total bases. Answer: Create a public method that will return the yards per carry (decimal) for a running back. To calculate yards per carry we start with 2 values - the number of yards gained, and the number of carries. Both yards and carries are int values only. To calculate the return value, divide the number of yards by the number of carries. The division (and method) should allow for the return of decimal values so integer division may need to be avoided. For example, if a player has 207 yards in 45 carries, the method would divide the two values and return 4.6 - each carry earned an average of 4.6 yards. If a player has 1254 yards in 287 carries, the method would return 4.369. Answer: Create a public method that will return the slugging percentage (decimal) for a baseball player. Slugging percentage is calculated as total bases divided by at bats. We created a method in number 3 that can determine the total bases when it knows the number of singles, doubles, triples, and home runs. This slugging percentage method should accept those four values again, like the total bases method, plus one additional int parameter for the number of at bats. In the end, there will be 5 int parameters defined in the signature. For the body we will divide the total bases by the at bats, but instead of listing the total bases math logic again, we should call the method defined in question 3. This method call requires 4 arguments to be passed and you will use the parameters dofinod in this now lunaina nanrantano mothind and nace them thenich to the total hacer nathod S O Type here to search DOLL Create a public method that will return the yards per carry (decimal) for a running back. To calculate yards per carry we start with 2 values - the number of yards gained, and the number of carries. Both yards and carries are int values only. To calculate the return value, divide the number of yards by the number of carries. The division (and method) should allow for the return of decimal values so integer division may need to be avoided. For example, if a player has 207 yards in 45 carries, the method would divide the two values and return 4.6 - each carry earned an average of 4.6 yards. If a player has 1254 yards in 287 carries, the method would return 4.369. Answer: public double calculateYardsPerCarry ( 5) Create a public method that will return the slugging percentage (decimal) for a baseball player. Slugging percentage is calculated as total bases divided by at bats. We created a method in number 3 that can determine the total bases when it knows the number of singles, doubles, triples, and home runs. This slugging percentage method should accept those four values again, like the total bases method, plus one additional int parameter for the number of at bats. In the end, there will be 5 int parameters defined in the signature. For the body we will divide the total bases by the at bats, but instead of listing the total bases math logic again, we should call the method defined in question 3. This method call requires 4 arguments to be passed and you will use the parameters defined in this new slugging percentage method and pass them through to the total bases method. For example, 10 singles, 4 doubles, i triple, 1 home run, 55 at bats - call total bases method nacin incinelo Horlod trinlahoma C and 4+ 11 netrinn 35 total hace than twice Windows (CRLE) O Type here to search DOLL

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

How to reverse a Armstrong number by using double linked list ?

Answered: 1 week ago