QBR/Slugging

import java.util.*; public class QBRSlugging { public QBRSlugging(){ Scanner sc = new Scanner(System.in); System.out.println("Welcome to QBR/Slugging, press 1 for QBR, 2 for slugging"); int either = Integer.parseInt(sc.nextLine()); if(either == 1){ System.out.println("Enter number of Completions"); int comp = Integer.parseInt(sc.nextLine()); System.out.println("Enter number of Passing Attempts"); int att = Integer.parseInt(sc.nextLine()); System.out.println("Enter passing Yards"); int yds = Integer.parseInt(sc.nextLine()); System.out.println("Enter number of Touchdown Passes"); int td = Integer.parseInt(sc.nextLine()); System.out.println("Enter number of Interceptions"); int inter = Integer.parseInt(sc.nextLine()); double a = (comp/att- 0.3) * 5.0; if( a > 2.375){ a = 2.375; } if( a < 0){ a = 0; } double b = (yds/att - 3) * 0.25; if( b > 2.375){ b = 2.375; } if( b < 0){ b = 0; } double c = (td/att) * 20; if( c > 2.375){ c = 2.375; } if( c < 0){ c = 0; } double d = 2.375 - (inter/att * 25); if( d > 2.375){ d = 2.375; } if( d < 0){ d = 0; } double pr =(( a + b + c + d)/6) * 100; System.out.println("The QBR is " + pr); } if(either == 2){ System.out.println("Enter at Bats"); double ab = Integer.parseInt(sc.nextLine()); System.out.println("Enter hits"); double hits = Integer.parseInt(sc.nextLine()); System.out.println("Enter doubles"); double doubles = Integer.parseInt(sc.nextLine()); System.out.println("Enter triples"); double triples = Integer.parseInt(sc.nextLine()); System.out.println("Enter home Runs"); double hr = Integer.parseInt(sc.nextLine()); double totalbases = hits + doubles + (2* triples) + (3* hr); double slg = totalbases/ab; System.out.println("Slugginer percent is " + slg); } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.