Below is the briefing for the assignment I am currently doing. The first part gi
ID: 3864424 • Letter: B
Question
Below is the briefing for the assignment I am currently doing. The first part gives a background and then the question follows the briefing. I will paste the code that I have done so far in the comments. My biggest issue is two fold. Curently my code is using outprints instead of dialogue boxes. I need to switch to dialogue boxes and a table if necissary. Secondly I am recieveing back some strange errors from my syntex that I can not fully decipher and fix.
NFL Quarterback Rating Formula
Four categories are used as a basis for compiling a rating:
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
The average standard, is 1.000. The bottom is .000. To earn a 2.000 rating, a passer must perform at exceptional levels, i.e., 70 percent in completions, 10 percent in touchdowns, 1.5 percent in interceptions, and 11 yards average gain per pass attempt. The maximum a passer can receive in any category is 2.375 (see examples at the end of the program).
In order to make the rating more understandable, the point rating is then converted into a scale of 100. In rare cases, where statistical performance has been superior, it is possible for a passer to surpass a 100 rating.
The four calculations would be:
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.
Note: If the result is less than zero (Comp. Pct. less than 30.0), award zero points. If the results are greater than 2.375 (Comp. Pct. greater than 77.5), award 2.375.
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.
Note: If the result is less than zero (yards per attempt less than 3.0), award zero points. If the result is greater than 2.375 (yards per attempt greater than 12.5), award 2.375 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.
Note: If the result is greater than 2.375 (touchdown percentage greater than 11.875), award 2.375.
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.
Note: If the result is less than zero (interception percentage greater than 9.5), award zero points.
The sum of the four steps is (2.014 + 1.403 + 1.518 + 1.833) 6.768. The sum is then divided by six (1.128) and multiplied by 100. In this case, the result is 112.8. This same formula can be used to determine a passer rating for any player who attempts at least one pass.
Question
In this program you are asked to compute the quarterback rating for an NFL quarterback. You will need to use methods for each of the Processing items and the output of your information. You do not have to have a method for the inputting of your data. Have your main call the methods and control the program.
Input:
Name String Quarterbacks Name
Completed Integer The number of completed passes
Attempts Integer The number of pass attempts
Yards Integer The number of receiving yards
Touchdowns Integer The number of passing TD’s
Interceptions Integer The number of passing Interceptions
Processing:
Rating Real Total of the following four
Percent Completion Real See above
Ave Yards Gained Real “
Percent of TD’s Real “
Percent of Int’s Real “
Output:
All data the user inputs, calculated variables from Processing and the Quarterbacks rating. You may
retrieve and display the data any way you would like.
Input and output should be done with Dialog and Message boxes. Your program should be well documented internally and externally.
What I have written
import java.util.Scanner;
public class QuarterbackEfficiencyRating {
public static void main(String[] args)
{
final double MIN_RATING = 0.0; // Min rating value
final double MAX_RATING = 2.375; // Max rating value
// Variables
String name; //The name of the quarterback
int attempts; // Number of attempts
int completions; // Number of completions
double yards; // Total Yards
int touchdowns; // Touchdowns
int interceptions; // Interceptions
// Declare and instantiate Scanner object
Scanner keyboard = new Scanner(System.in);
// Prompt user to input the name quarterback
System.out.print("Enter quarteback's name>");
name = keyboard.nextLine();
// Prompt user to input attempts
System.out.print("Enter number of attempts>");
attempts = keyboard.nextInt();
// Prompt user to input completions
System.out.print("Enter number of completions>");
completions = keyboard.nextInt();
//Prompt user to input total yards
System.out.print("Enter total yards>");
yards = keyboard.nextInt();
//Prompt user to input touchdowns
System.out.print("Enter number of touchtowns>");
touchdowns = keyboard.nextInt();
//Prompt user to input number of interceptions
System.out.print("Enter number of interceptions>");
interceptions = keyboard.nextInt();
//Calculation variables
double comp; //percentage of completions per attempt
double yds; // average yards gained per attempt
double tds; //percentage of touchdown passes per attempt
double ints; //percentages of interceptions per attempt
double QBER; //Quarterback Efficiency rating
//Calculates COMP
comp = 0.05 * (((100.0 * completions) / attempts) - 30);
comp = Math.min(comp, MAX_RATING); // If comp > MAX_RATING then set comp to MAX_RATING
comp = Math.max(comp, MIN_RATING); // if comp < MIN_RATING then set comp to MIN_RATING
//Calculates yds
yds = 0.25 * ((yards / attempts) - 3.0);
yds = Math.min(yds, MAX_RATING); // If yds > MAX_RATING then set yds to MAX_RATING
yds = Math.max(yds, MIN_RATING); // if yds < MIN_RATING then set yds to MIN_RATING
//Calculates tds
tds = 0.2 * (100.0 * touchdowns / attempts);
tds = Math.min(tds, MAX_RATING); // If tds > MAX_RATING then set yds to MAX_RATING
//Calculates ints
ints = 2.375 - 0.25 * (100.0 * interceptions / attempts);
ints = Math.min(ints, MAX_RATING); // If ints > MAX_RATING then set yds to MAX_RATING
//Calculates QBER
QBER = 100 * (comp + yds + tds + ints) / 6;
//Display the QBER
System.out.println(""
QBER Ananlysis for " + name"
+ ""
COMP = " + comp"
+ ""
YDS = " + yds"
+ ""
TDS = " + tds"
+ ""
INTS = " + ints"
+ "\"
QBER = " + QBER)";
}
}
Explanation / Answer
import java.util.Scanner;
public class QuarterbackEfficiencyRating {
public static void main(String[] args)
{
final double MIN_RATING = 0.0; // Min rating value
final double MAX_RATING = 2.375; // Max rating value
// Variables
String name; //The name of the quarterback
int attempts; // Number of attempts
int completions; // Number of completions
double yards; // Total Yards
int touchdowns; // Touchdowns
int interceptions; // Interceptions
// Declare and instantiate Scanner object
Scanner keyboard = new Scanner(System.in);
// Prompt user to input the name quarterback
System.out.print("Enter quarteback's name>");
name = keyboard.nextLine();
// Prompt user to input attempts
System.out.print("Enter number of attempts>");
attempts = keyboard.nextInt();
// Prompt user to input completions
System.out.print("Enter number of completions>");
completions = keyboard.nextInt();
//Prompt user to input total yards
System.out.print("Enter total yards>");
yards = keyboard.nextInt();
System.out.print("Enter number of touchtowns>");
touchdowns = keyboard.nextInt();
System.out.print("Enter number of interceptions>");
interceptions = keyboard.nextInt();
single comp;
double yds; // average yards gained per attempt
double tds; //percentage of touchdown passes per attempt
double ints; //percentages of interceptions per attempt
double QBER; //Quarterback Efficiency rating
//Calculates COMP
comp = 0.05 * (((100.0 * completions) / attempts) - 30);
comp = Math.min(comp, MAX_RATING); // If comp > MAX_RATING then set comp to MAX_RATING
comp = Math.max(comp, MIN_RATING); // if comp < MIN_RATING then set comp to MIN_RATING
//Calculates yds
yds = 0.25 * ((yards / attempts) - 3.0);
yds = Math.min(yds, MAX_RATING); // If yds > MAX_RATING then set yds to MAX_RATING
yds = Math.max(yds, MIN_RATING); // if yds < MIN_RATING then set yds to MIN_RATING
//Calculates tds
tds = 0.2 * (100.0 * touchdowns / attempts);
tds = Math.min(tds, MAX_RATING); // If tds > MAX_RATING then set yds to MAX_RATING
//Calculates ints
ints = 2.375 - 0.25 * (100.0 * interceptions / attempts);
ints = Math.min(ints, MAX_RATING); // If ints > MAX_RATING then set yds to MAX_RATING
//Calculates QBER
QBER = 100 * (comp + yds + tds + ints) / 6;
//Display the QBER
System.out.println(""
QBER Ananlysis for " + name"
+ ""
COMP = " + comp"
+ ""
YDS = " + yds"
+ ""
TDS = " + tds"
+ ""
INTS = " + ints"
+ "\"
QBER = " + QBER)";
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.