Advertisement
yeah568

/g/ for mike in c#

May 3rd, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication3 {
  8.     class Program {
  9.         static void Main(string[] args) {
  10.             Console.WriteLine("Please enter a letter grade.");
  11.             Console.Write(">>>");
  12.             var letterGrade = Console.ReadLine();
  13.             Dictionary<string, double> gradeConversion =
  14.                 new Dictionary<string, double>()
  15.             {
  16.                 {"A", 4.0},
  17.                 {"B", 3.0},
  18.                 {"C", 2.0},
  19.                 {"D", 1.0},
  20.                 {"F", 0.0}
  21.             };
  22.             Dictionary<string, double> signs =
  23.                 new Dictionary<string, double>()
  24.             {
  25.                 {"+", 0.3},
  26.                 {"-", -0.3},
  27.             };
  28.             if (letterGrade.Length == 1) {
  29.                 Console.WriteLine(gradeConversion[letterGrade]);
  30.             }
  31.             else if (letterGrade.Length == 2) {
  32.                 double tempGrade = gradeConversion[letterGrade[0].ToString()];
  33.                 tempGrade += signs[letterGrade[1].ToString()];
  34.                 Console.WriteLine(tempGrade);
  35.             }
  36.             else {
  37.                 Console.WriteLine("YOU HAVE FUCKED UP NOW");
  38.             }
  39.             Console.WriteLine("Press any key to exit.");
  40.             Console.ReadLine();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement