Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am stuck on my current assignment. My assignment is for the Quarterback Rating Formula and says: Processing is needed for the five categories below.

I am stuck on my current assignment. My assignment is for the Quarterback Rating Formula and says:

Processing is needed for the five categories below. Each of these calculations should be in its own method for processing.

1. Percentage of completions per attempt 2. Average yards gained per attempt 3. Percentage of touchdown passes per attempt 4. Percentage of interceptions per attempt

5. Rushing yards

The five calculations would be: (below includes an example of 324 completions, 461 attempts, 3969 yards, 35 tds and 10 ints)

Percentage of Completions 324 of 461 is 70.28 percent. Subtract 30 from the completion percentage (40.28) and multiply the result by 0.05. The result is a point rating of 2.014. Multiply it by 8 and return the int of the number. If the result is less than zero award zero points. If it is over 20, award 20 points.

Average Yards Gained Per Attempt 3,969 yards divided by 461 attempts is 8.61. Subtract three yards from yards-per-attempt (5.61) and multiply the result by 0.25. The result is 1.403. Multiply it by 9 and return the int of the number. If the result is less than zero award zero points. If it is over 20, award 20 points.

Percentage of Touchdown Passes 35 touchdowns in 461 attempts is 7.59 percent. Multiply the touchdown percentage by 0.2. The result is 1.518. Multiply it by 9 and return the int of the number. If the result is less than zero award zero points. If it is over 20, award 20 points.

Percentage of Interceptions 10 interceptions in 461 attempts is 2.17 percent. Multiply the interception percentage by 0.25 (0.542) and subtract the number from 2.375. The result is 1.833. Multiply it by 10 and return the int of the number. If the result is less than zero award zero points. If it is over 20, award 20 points.

Rushing yards - return a number based on taking the number of rushing yards and div it by 5. The max number that can be returned is 20. For example, if a quarterback rushed for 63 yards, you would return a score of 12.

Each of the steps have a max of 20, so the sum could equal a max of 100.

I have the following code for Java:

public static void main(String[] args) { String name; int attemptedPasses; double completedPasses; double totalYardsGained; double touchdowns; double interceptions; double yardsRushing; double rating; String input; displayOutput(attemptedPasses, name, rating, completedPasses, totalYardsGained, touchdowns, interceptions, yardsRushing);

name = JOptionPane.showInputDialog("Quarterback name: ");

input = JOptionPane.showInputDialog("Number of completed passes: "); completedPasses = Integer.parseInt(input);

input = JOptionPane.showInputDialog("Number of attempted passes: "); attemptedPasses = Integer.parseInt(input);

input = JOptionPane.showInputDialog("Number of receiving yards: "); totalYardsGained = Integer.parseInt(input);

input = JOptionPane.showInputDialog("Number of touchdowns: "); touchdowns = Integer.parseInt(input);

input = JOptionPane.showInputDialog("Number of interceptions: "); interceptions = Integer.parseInt(input);

input = JOptionPane.showInputDialog("Number of yards rushed: "); yardsRushing = Integer.parseInt(input); } public static double completedPasses(int attemptedPasses) { String input; double completedPasses; completedPasses = (((completedPasses/attemptedPasses)-30)* 5) *8; if(completedPasses < 0) { completedPasses = 0; } if(completedPasses > 20) { completedPasses = 20; } return completedPasses; }

public static int attemptedPasses() { String input; int attemptedPasses; return attemptedPasses; }

public static double totalYardsGain(int attempts) { String input; double yards; yards = (((yards/attempts)-3)*.25) * 9; if(yards < 0) { yards = 0; } if(yards > 20) { yards = 20; } return yards; }

public static double touchdowns(int attempts) { String input; double touchdowns; touchdowns = ((touchdowns/attempts)*.2) * 9; if(touchdowns < 0) { touchdowns = 0; } if(touchdowns > 0) { touchdowns = 20; } return touchdowns; } public static double interceptions(int attempts) { String input; double interceptions; interceptions = (2.375-(interceptions/attempts)*.25) * 10; if(interceptions < 0) { interceptions = 0; } if(interceptions > 0) { interceptions = 20; } return interceptions; } public static double yardsRushing() { String input; double rushingYards; rushingYards = rushingYards/5; if(rushingYards < 0) { rushingYards = 0; } if(rushingYards > 0) { rushingYards = 20; } return rushingYards; } public static double getPasserRate(double completed, double yards, double touchdowns, double interceptions, double rushingYards) { double rate; rate=((completed + yards + touchdowns + interceptions) / 6) * 100; return rate; }

public static void displayOutput(int attemptedPasses, String name, double rating, double completedPasses, double totalYardsGained, double touchdowns, double interceptions, double yardsRushing) { DecimalFormat formatter = new DecimalFormat("#0"); JOptionPane.showMessageDialog(null, name + "'s overall rating is " + formatter.format(rating) + " The total completed passes is " + attemptedPasses + " The number of completed passes " + formatter.format(completedPasses) + " The number of receiving yards is " + formatter.format(totalYardsGained) + " The number passing touchdowns is " + formatter.format(touchdowns) + " The number of passing interceptions is " + formatter.format(interceptions) + " The number of yards the quarterback rushes is " + formatter.format(yardsRushing)); System.exit(0);

} }

My instructor wants me to "call your calculation methods and pass in the values for each of your methods." How do I do this?

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

Students also viewed these Databases questions

Question

Evaluate employees readiness for training. page 275

Answered: 1 week ago