Advertisement
Tidall

Grade Calc

Oct 14th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.48 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 GradeCalculatorConsole
  8. {
  9.     class Program
  10.     {
  11.  
  12.         static string userChoice, choice, confirm;
  13.         static int choiceConfirm;
  14.         // 1 = gpa 0 = money
  15.  
  16.         static string standardchar, honorschar, apchar, stanclass1, stanclass2, stanclass3, stanclass4, honclass1, honclass2, honclass3, honclass4, apclass1, apclass2, apclass3, apclass4;
  17.         static int standard, honors, ap;
  18.  
  19.         //static double total;
  20.  
  21.         static void Main(string[] args)
  22.         {
  23.             showWelcomeMessage();
  24.             gorm();
  25.  
  26.             getGradePoints();
  27.  
  28.             consoleNoClose();
  29.         }
  30.  
  31.         static void showWelcomeMessage()
  32.         {
  33.             Console.WriteLine(" =========================================================");
  34.             Console.WriteLine("||    _____         _          _____           _         ||");
  35.             Console.WriteLine("||   |__   |___ ___| |_ ___   |   __|___ ___ _| |___     ||");
  36.             Console.WriteLine("||   |   __| .'|  _|   |_ -|  |  |  |  _| .'| . | -_|    ||");
  37.             Console.WriteLine("||   |_____|__,|___|_|_|___|  |_____|_| |__,|___|___|    ||");
  38.             Console.WriteLine("||                                                       ||");
  39.             Console.WriteLine("||         _____     _         _     _                   ||");
  40.             Console.WriteLine("||        |     |___| |___ _ _| |___| |_ ___ ___         ||");
  41.             Console.WriteLine("||        |   --| .'| |  _| | | | .'|  _| . |  _|        ||");
  42.             Console.WriteLine("||        |_____|__,|_|___|___|_|__,|_| |___|_|          ||");
  43.             Console.WriteLine("||                                                       ||");
  44.             Console.WriteLine(" =========================================================");
  45.             Console.WriteLine();
  46.             Console.WriteLine("=======================================");
  47.             Console.WriteLine("Welcome to Zach's Grade Calculator V2");
  48.             Console.WriteLine("=======================================");
  49.             Console.WriteLine();
  50.         }
  51.  
  52.         static void gpaCalculate()
  53.         {
  54.             Console.Clear();
  55.             Console.WriteLine("GPA Calculator Initialized");
  56.             Console.WriteLine("=======================================");
  57.             Console.WriteLine("This is calculated using the weighted gpa system:");
  58.             Console.WriteLine("Standard A = 4 | Honors A = 4.5 | AP A = 5");
  59.             Console.WriteLine("Standard B = 3 | Honors B = 3.5 | AP B = 4");
  60.             Console.WriteLine("Standard C = 2 | Honors C = 2.5 | AP C = 3");
  61.             Console.WriteLine("Standard D = 1 | Honors D = 1.5 | AP D = 2");
  62.             Console.WriteLine("Standard F = 0 | Honors F = 0.5 | AP F = 1");
  63.             Console.WriteLine("=======================================");
  64.  
  65.             getGrades();
  66.  
  67.            // total = getGradePoints();
  68.  
  69.  
  70.  
  71.            
  72.  
  73.            
  74.         }
  75.  
  76.         static void getGradePoints() //change back to a double return
  77.         {
  78.             // total = 0;
  79.             //return total;
  80.  
  81.             Console.WriteLine("---------");
  82.  
  83.             Console.WriteLine(stanclass1);
  84.             Console.WriteLine("stan class 1 ^");
  85.             Console.WriteLine(stanclass2);
  86.             Console.WriteLine("stan class 2 ^");
  87.             Console.WriteLine(honclass1);
  88.             Console.WriteLine("hon class 1 ^");
  89.             Console.WriteLine(honclass2);
  90.             Console.WriteLine("hon class 2 ^");
  91.  
  92.             Console.WriteLine("---------");
  93.         }
  94.  
  95.         static void getGrades()
  96.         {
  97.  
  98.  
  99.  
  100.                 Console.WriteLine("How many grade level classes are you taking?");
  101.                 standardchar = Console.ReadLine();
  102.                 standard = int.Parse(standardchar);
  103.                 Console.WriteLine();
  104.  
  105.                 Console.WriteLine("How many honors level classes are you taking?");
  106.                 honorschar = Console.ReadLine();
  107.                 honors = int.Parse(honorschar);
  108.                 Console.WriteLine();
  109.  
  110.                 Console.WriteLine("How many AP level classes are you taking?");
  111.                 apchar = Console.ReadLine();
  112.                 ap = int.Parse(apchar);
  113.                 Console.WriteLine();
  114.  
  115.                 int i = 1;
  116.                 while (i < standard + 1)
  117.                 {
  118.                     Console.WriteLine("Enter letter grade for standard class {0}", i);
  119.  
  120.                     if (standard == 1)
  121.                     {
  122.                         stanclass1 = Console.ReadLine();
  123.                     }
  124.                     else if (standard == 2)
  125.                     {
  126.                         stanclass2 = Console.ReadLine();
  127.                     }
  128.                     else if (standard == 3)
  129.                     {
  130.                         stanclass3 = Console.ReadLine();
  131.                     }
  132.                     else if (standard == 4)
  133.                     {
  134.                         stanclass4 = Console.ReadLine();
  135.                     }
  136.                     else
  137.                     {
  138.                     break;
  139.                     }
  140.  
  141.                 i++;
  142.                 }
  143.  
  144.                 i = 1;
  145.                 while (i < honors + 1)
  146.                 {
  147.                     Console.WriteLine("Enter letter grade for Honors class {0}", i);
  148.  
  149.                     if (honors == 1)
  150.                     {
  151.                         honclass1 = Console.ReadLine();
  152.                     }
  153.                     else if (honors == 2)
  154.                     {
  155.                         honclass2 = Console.ReadLine();
  156.                     }
  157.                     else if (honors == 3)
  158.                     {
  159.                         honclass3 = Console.ReadLine();
  160.                     }
  161.                     else if (honors == 4)
  162.                     {
  163.                         honclass4 = Console.ReadLine();
  164.                     }
  165.                     else
  166.                     {
  167.                     break;
  168.                     }
  169.  
  170.                 i++;
  171.                 }
  172.  
  173.                 i = 1;
  174.                 while (i < ap + 1)
  175.                 {
  176.                     Console.WriteLine("Enter letter grade for ap class {0}", i);
  177.  
  178.                     if (ap == 1)
  179.                     {
  180.                         apclass1 = Console.ReadLine();
  181.                     }
  182.                     else if (ap == 2)
  183.                     {
  184.                         apclass2 = Console.ReadLine();
  185.                     }
  186.                     else if (ap == 3)
  187.                     {
  188.                         apclass3 = Console.ReadLine();
  189.                     }
  190.                     else if (ap == 4)
  191.                     {
  192.                         apclass4 = Console.ReadLine();
  193.                     }
  194.                     else
  195.                     {
  196.                     break;
  197.                     }
  198.                 }
  199.                 i++;
  200.  
  201.  
  202.         }
  203.  
  204.         static void moneyCalculate()
  205.         {
  206.             Console.Clear();
  207.             Console.WriteLine("Money Calculator Initialized");
  208.         }
  209.  
  210.         static void gorm()
  211.         {
  212.             Console.WriteLine("What would you like to do?");
  213.             Console.WriteLine();
  214.             Console.WriteLine("Type GPA for a GPA Calculator, type MONEY for a money calculator.");
  215.             Console.WriteLine("=======================================");
  216.             userChoice = Console.ReadLine();
  217.  
  218.             userChoice = userChoice.ToUpper();
  219.             Console.WriteLine(userChoice);
  220.  
  221.             switch(userChoice)
  222.             {
  223.                 case "GPA":
  224.                     choiceConfirm = 1;
  225.                     choice = "GPA Calculator";
  226.                     break;
  227.                 case "MONEY":
  228.                     choiceConfirm = 0;
  229.                     choice = "Money Calculator";
  230.                     break;
  231.                 default:
  232.                     Console.WriteLine("Invalid choice, reenter.");
  233.                     Console.WriteLine("=======================================");
  234.                     gorm();
  235.                     break;
  236.             }
  237.  
  238.             confirmChoice();
  239.  
  240.         }
  241.  
  242.         static void confirmChoice()
  243.         {
  244.             Console.WriteLine("=======================================");
  245.             Console.WriteLine("You chose: {0}.", choice);
  246.             Console.WriteLine();
  247.             Console.WriteLine("Confirm your choice Y/N:");
  248.             Console.WriteLine("=======================================");
  249.             confirm = Console.ReadLine();
  250.  
  251.             confirm = confirm.ToUpper();
  252.             confirm.ToUpper();
  253.  
  254.             if (confirm == "Y")
  255.             {
  256.                 if (choiceConfirm == 1)
  257.                 {
  258.                     gpaCalculate();
  259.                 }
  260.                 else if (choiceConfirm == 0)
  261.                 {
  262.                     moneyCalculate();
  263.                 }
  264.  
  265.             }
  266.             else if (confirm == "N")
  267.             {
  268.                 gorm();
  269.             }
  270.             else
  271.             {
  272.                 Console.WriteLine();
  273.                 Console.WriteLine("Error: Invalid Format reenter");
  274.                 confirmChoice();
  275.             }
  276.  
  277.         }
  278.  
  279.         static void consoleNoClose()
  280.         {
  281.             Console.WriteLine();
  282.             Console.WriteLine();
  283.             Console.WriteLine("Press Any Key to Exit . . .");
  284.             Console.ReadKey();
  285.         }
  286.     }
  287. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement