Advertisement
Tidall

Grade Calc

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