qbr/slugging

import java.util.*; public class QBRAndSlugging{ public static void main(String arg[]){ Scanner sc = new Scanner(System.in); System.out.println("QBR: "); System.out.println("Enter number of attempted passes"); double att = sc.nextDouble(); System.out.println("Enter number of completions"); double comp = sc.nextDouble(); System.out.println("Enter number of passing yards"); double yrds = sc.nextDouble(); System.out.println("Enter number of touchdowns"); double tds = sc.nextDouble(); System.out.println("Enter number of interceptions"); double ints = sc.nextDouble(); double a = ((comp/att)-.3) * 5; if(a>2.375) a = 2.375; if(a<0) a = 0; double b = ((yrds/att)-3) * .25; if(b>2.375) b = 2.375; if(b<0) b = 0; double c = (tds/att) * 20; if(c>2.375) c = 2.375; if(c<0) c = 0; double d = 2.375 - ((ints/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("Passer Rating: " + (int)pr); System.out.println(""); System.out.println("Slugging: "); System.out.println("Enter number of at bats"); double ab = sc.nextDouble(); System.out.println("Enter number of hits"); double hits = sc.nextDouble(); System.out.println("Enter number of doubles"); double doub = sc.nextDouble(); System.out.println("Enter number of triples"); double trip = sc.nextDouble(); System.out.println("Enter number of home runs"); double hr = sc.nextDouble(); double sing = hits - trip - doub - hr; double tb = sing + (2*doub) + (3*trip) + (4*hr); double slg = tb/ab; System.out.println("Slugging Percentage: " + 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.