Guest User

Untitled

a guest
May 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. using System;
  2. class QBR
  3. {
  4.     public static void Main()
  5.     {
  6.         start:
  7.         string Completions, Attempts, Touchdowns, Interceptions, Yards;
  8.         double completions, attempts, touchdowns, interceptions, yards;
  9.  
  10.         Console.Write("Completions: ");
  11.         Completions = Console.ReadLine();
  12.         double.TryParse(Completions, out completions);
  13.  
  14.         Console.Write("Attempts: ");
  15.         Attempts = Console.ReadLine();
  16.         double.TryParse(Attempts, out attempts);
  17.  
  18.         Console.Write("Touchdowns: ");
  19.         Touchdowns = Console.ReadLine();
  20.         double.TryParse(Touchdowns, out touchdowns);
  21.  
  22.         Console.Write("Interceptions: ");
  23.         Interceptions = Console.ReadLine();
  24.         double.TryParse(Interceptions, out interceptions);
  25.  
  26.         Console.Write("Yards: ");
  27.         Yards = Console.ReadLine();
  28.         double.TryParse(Yards, out yards);
  29.  
  30.         double a, b, c, d, rating, finalrating;
  31.         a = (((completions / attempts) * 100) - 30) / 20.0;
  32.         b = ((touchdowns / attempts) * 100) / 5.0;
  33.         c=(9.5-((interceptions/attempts)*100))/4.0;
  34.         d=((yards/attempts)-3)/4.0;
  35.         rating = ((a+b+c+d)/6.0)*100;
  36.         finalrating = Math.Round(rating, 1);
  37.         if (finalrating > 158.3)
  38.         {
  39.             Console.WriteLine("Error: Invalid Data");
  40.                 goto start;
  41.         }
  42.         if (finalrating < 0)
  43.         {
  44.             Console.WriteLine("Error: Invalid Data");
  45.             goto start;
  46.         }
  47.         else
  48.         {
  49.             Console.WriteLine("Quarterback Rating: {0}", finalrating);
  50.             goto start;
  51.         }
  52.     }
  53. }
Add Comment
Please, Sign In to add comment