Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace GradeCalculatorConsole
- {
- class Program
- {
- static string userChoice, choice, confirm;
- static int choiceConfirm;
- // 1 = gpa 0 = money 2 = exit
- static string standardchar, honorschar, apchar, stanclass2, stanclass3, stanclass4, honclass2, honclass3, honclass4, apclass1, apclass2, apclass3, apclass4;
- static int standard, honors, ap;
- static string stanclass1, honclass1;
- static string rgrade1, rgrade2, rgrade3, rgrade4;
- static int agrade, bgrade, cgrade, dgrade, fgrade;
- static void Main(string[] args)
- {
- Process();
- }
- static void Process()
- {
- Console.Clear();
- showWelcomeMessage();
- gorm();
- consoleNoClose();
- }
- #region menu
- static void showWelcomeMessage()
- {
- Console.WriteLine(" =========================================================");
- Console.WriteLine("|| _____ _ _____ _ ||");
- Console.WriteLine("|| |__ |___ ___| |_ ___ | __|___ ___ _| |___ ||");
- Console.WriteLine("|| | __| .'| _| |_ -| | | | _| .'| . | -_| ||");
- Console.WriteLine("|| |_____|__,|___|_|_|___| |_____|_| |__,|___|___| ||");
- Console.WriteLine("|| ||");
- Console.WriteLine("|| _____ _ _ _ ||");
- Console.WriteLine("|| | |___| |___ _ _| |___| |_ ___ ___ ||");
- Console.WriteLine("|| | --| .'| | _| | | | .'| _| . | _| ||");
- Console.WriteLine("|| |_____|__,|_|___|___|_|__,|_| |___|_| ||");
- Console.WriteLine("|| ||");
- Console.WriteLine(" =========================================================");
- Console.WriteLine();
- Console.WriteLine("=======================================");
- Console.WriteLine("Welcome to Zach's Grade Calculator V2");
- Console.WriteLine("=======================================");
- Console.WriteLine();
- }
- static void gorm()
- {
- Console.WriteLine("What would you like to do?");
- Console.WriteLine();
- Console.WriteLine("Type GPA for a GPA Calculator.");
- Console.WriteLine("Type MONEY for a money calculator.");
- Console.WriteLine("Type EXIT to exit the calculator.");
- Console.WriteLine("=======================================");
- userChoice = Console.ReadLine();
- userChoice = userChoice.ToUpper();
- Console.WriteLine(userChoice);
- switch (userChoice)
- {
- case "GPA":
- choiceConfirm = 1;
- choice = "GPA Calculator";
- break;
- case "MONEY":
- choiceConfirm = 0;
- choice = "Money Calculator";
- break;
- case "EXIT":
- choiceConfirm = 2;
- choice = "EXIT";
- break;
- default:
- Console.WriteLine("Invalid choice, reenter.");
- Console.WriteLine("=======================================");
- gorm();
- break;
- }
- confirmChoice();
- }
- static void confirmChoice()
- {
- Console.WriteLine("=======================================");
- Console.WriteLine("You chose: {0}.", choice);
- Console.WriteLine();
- Console.WriteLine("Confirm your choice Y/N:");
- Console.WriteLine("=======================================");
- confirm = Console.ReadLine();
- confirm = confirm.ToUpper();
- confirm.ToUpper();
- if (confirm == "Y")
- {
- if (choiceConfirm == 1)
- {
- gpaCalculate();
- }
- else if (choiceConfirm == 0)
- {
- moneyCalculate();
- }
- else if (choiceConfirm == 2)
- {
- System.Environment.Exit(0);
- }
- }
- else if (confirm == "N")
- {
- gorm();
- }
- else
- {
- Console.WriteLine();
- Console.WriteLine("Error: Invalid Format reenter");
- confirmChoice();
- }
- }
- #endregion
- #region gpa
- static void gpaCalculate()
- {
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine("GPA Calculator Initialized");
- Console.WriteLine("=======================================");
- Console.WriteLine("This is calculated using the weighted gpa system:");
- Console.WriteLine("Standard A = 4 | Honors A = 4.5 | AP A = 5");
- Console.WriteLine("Standard B = 3 | Honors B = 3.5 | AP B = 4");
- Console.WriteLine("Standard C = 2 | Honors C = 2.5 | AP C = 3");
- Console.WriteLine("Standard D = 1 | Honors D = 1.5 | AP D = 2");
- Console.WriteLine("Standard F = 0 | Honors F = 0.5 | AP F = 1");
- Console.WriteLine("=======================================");
- Console.WriteLine("Currently only supports 1 semester of 4 block classes");
- Console.WriteLine("=======================================");
- getGrades();
- double points = getGradePoints();
- int classnum = standard + honors + ap;
- double gpa = points / classnum;
- Console.WriteLine();
- Console.WriteLine("=======================================");
- Console.WriteLine("Your GPA has been Calculated!");
- Console.WriteLine("=======================================");
- Console.WriteLine("Your single semester GPA is: {0}", gpa);
- Console.WriteLine();
- Console.WriteLine("Press any key to return to the menu.");
- Console.ReadKey();
- Process();
- }
- static void getGrades()
- {
- //throws FormatException if char is entered
- stanclass1 = "";
- stanclass2 = "";
- stanclass3 = "";
- stanclass4 = "";
- honclass1 = "";
- honclass2 = "";
- honclass3 = "";
- honclass4 = "";
- apclass1 = "";
- apclass2 = "";
- apclass3 = "";
- apclass4 = "";
- try
- {
- Console.WriteLine("How many grade level classes are you taking?");
- standardchar = Console.ReadLine();
- standard = int.Parse(standardchar);
- Console.WriteLine();
- Console.WriteLine("How many honors level classes are you taking?");
- honorschar = Console.ReadLine();
- honors = int.Parse(honorschar);
- Console.WriteLine();
- Console.WriteLine("How many AP level classes are you taking?");
- apchar = Console.ReadLine();
- ap = int.Parse(apchar);
- Console.WriteLine();
- }
- catch (FormatException)
- {
- Console.WriteLine("ERROR:");
- Console.WriteLine("You have input an incorrect character, retry. You will need to reneter grades.");
- getGrades();
- }
- int i = 1;
- while (i <= standard)
- {
- Console.WriteLine("Enter letter grade for grade level class {0}", i);
- if (i == 1)
- {
- stanclass1 = Console.ReadLine();
- }
- else if (i == 2)
- {
- stanclass2 = Console.ReadLine();
- }
- else if (i == 3)
- {
- stanclass3 = Console.ReadLine();
- }
- else if (i == 4)
- {
- stanclass4 = Console.ReadLine();
- }
- else
- {
- break;
- }
- i++;
- }
- i = 1;
- while (i <= honors)
- {
- Console.WriteLine("Enter letter grade for honors level class {0}", i);
- if (i == 1)
- {
- honclass1 = Console.ReadLine();
- }
- else if (i == 2)
- {
- honclass2 = Console.ReadLine();
- }
- else if (i == 3)
- {
- honclass3 = Console.ReadLine();
- }
- else if (i == 4)
- {
- honclass4 = Console.ReadLine();
- }
- else
- {
- break;
- }
- i++;
- }
- i = 1;
- while (i <= ap)
- {
- Console.WriteLine("Enter Letter grade for AP level class {0}", i);
- if (i == 1)
- {
- apclass1 = Console.ReadLine();
- }
- else if (i == 2)
- {
- apclass2 = Console.ReadLine();
- }
- else if (i == 3)
- {
- apclass3 = Console.ReadLine();
- }
- else if (i == 4)
- {
- apclass4 = Console.ReadLine();
- }
- else
- {
- break;
- }
- i++;
- }
- }
- static double getGradePoints() //change back to a double return
- {
- double total = 0.0;
- #region stan
- switch (stanclass1)
- {
- case "A":
- total = total + 4.0;
- break;
- case "a":
- total = total + 4.0;
- break;
- case "B":
- total = total + 3.0;
- break;
- case "b":
- total = total + 3.0;
- break;
- case "C":
- total = total + 2.0;
- break;
- case "c":
- total = total + 2.0;
- break;
- case "D":
- total = total + 1.0;
- break;
- case "d":
- total = total + 1.0;
- break;
- case "F":
- total = total + 0.0;
- break;
- case "f":
- total = total + 0.0;
- break;
- default:
- break;
- }
- switch (stanclass2)
- {
- case "A":
- total = total + 4.0;
- break;
- case "a":
- total = total + 4.0;
- break;
- case "B":
- total = total + 3.0;
- break;
- case "b":
- total = total + 3.0;
- break;
- case "C":
- total = total + 2.0;
- break;
- case "c":
- total = total + 2.0;
- break;
- case "D":
- total = total + 1.0;
- break;
- case "d":
- total = total + 1.0;
- break;
- case "F":
- total = total + 0.0;
- break;
- case "f":
- total = total + 0.0;
- break;
- default:
- break;
- }
- switch (stanclass3)
- {
- case "A":
- total = total + 4.0;
- break;
- case "a":
- total = total + 4.0;
- break;
- case "B":
- total = total + 3.0;
- break;
- case "b":
- total = total + 3.0;
- break;
- case "C":
- total = total + 2.0;
- break;
- case "c":
- total = total + 2.0;
- break;
- case "D":
- total = total + 1.0;
- break;
- case "d":
- total = total + 1.0;
- break;
- case "F":
- total = total + 0.0;
- break;
- case "f":
- total = total + 0.0;
- break;
- default:
- break;
- }
- switch (stanclass4)
- {
- case "A":
- total = total + 4.0;
- break;
- case "a":
- total = total + 4.0;
- break;
- case "B":
- total = total + 3.0;
- break;
- case "b":
- total = total + 3.0;
- break;
- case "C":
- total = total + 2.0;
- break;
- case "c":
- total = total + 2.0;
- break;
- case "D":
- total = total + 1.0;
- break;
- case "d":
- total = total + 1.0;
- break;
- case "F":
- total = total + 0.0;
- break;
- case "f":
- total = total + 0.0;
- break;
- default:
- break;
- }
- #endregion
- #region hon
- switch (honclass1)
- {
- case "A":
- total = total + 4.5;
- break;
- case "a":
- total = total + 4.5;
- break;
- case "B":
- total = total + 3.5;
- break;
- case "b":
- total = total + 3.5;
- break;
- case "C":
- total = total + 2.5;
- break;
- case "c":
- total = total + 2.5;
- break;
- case "D":
- total = total + 1.5;
- break;
- case "d":
- total = total + 1.5;
- break;
- case "F":
- total = total + 0.5;
- break;
- case "f":
- total = total + 0.5;
- break;
- default:
- break;
- }
- switch (honclass2)
- {
- case "A":
- total = total + 4.5;
- break;
- case "a":
- total = total + 4.5;
- break;
- case "B":
- total = total + 3.5;
- break;
- case "b":
- total = total + 3.5;
- break;
- case "C":
- total = total + 2.5;
- break;
- case "c":
- total = total + 2.5;
- break;
- case "D":
- total = total + 1.5;
- break;
- case "d":
- total = total + 1.5;
- break;
- case "F":
- total = total + 0.5;
- break;
- case "f":
- total = total + 0.5;
- break;
- default:
- break;
- }
- switch (honclass3)
- {
- case "A":
- total = total + 4.5;
- break;
- case "a":
- total = total + 4.5;
- break;
- case "B":
- total = total + 3.5;
- break;
- case "b":
- total = total + 3.5;
- break;
- case "C":
- total = total + 2.5;
- break;
- case "c":
- total = total + 2.5;
- break;
- case "D":
- total = total + 1.5;
- break;
- case "d":
- total = total + 1.5;
- break;
- case "F":
- total = total + 0.5;
- break;
- case "f":
- total = total + 0.5;
- break;
- default:
- break;
- }
- switch (honclass4)
- {
- case "A":
- total = total + 4.5;
- break;
- case "a":
- total = total + 4.5;
- break;
- case "B":
- total = total + 3.5;
- break;
- case "b":
- total = total + 3.5;
- break;
- case "C":
- total = total + 2.5;
- break;
- case "c":
- total = total + 2.5;
- break;
- case "D":
- total = total + 1.5;
- break;
- case "d":
- total = total + 1.5;
- break;
- case "F":
- total = total + 0.5;
- break;
- case "f":
- total = total + 0.5;
- break;
- default:
- break;
- }
- #endregion
- #region ap
- switch (apclass1)
- {
- case "A":
- total = total + 5.0;
- break;
- case "a":
- total = total + 5.0;
- break;
- case "B":
- total = total + 4.0;
- break;
- case "b":
- total = total + 4.0;
- break;
- case "C":
- total = total + 3.0;
- break;
- case "c":
- total = total + 3.0;
- break;
- case "D":
- total = total + 2.0;
- break;
- case "d":
- total = total + 2.0;
- break;
- case "F":
- total = total + 1.0;
- break;
- case "f":
- total = total + 1.0;
- break;
- default:
- break;
- }
- switch (apclass2)
- {
- case "A":
- total = total + 5.0;
- break;
- case "a":
- total = total + 5.0;
- break;
- case "B":
- total = total + 4.0;
- break;
- case "b":
- total = total + 4.0;
- break;
- case "C":
- total = total + 3.0;
- break;
- case "c":
- total = total + 3.0;
- break;
- case "D":
- total = total + 2.0;
- break;
- case "d":
- total = total + 2.0;
- break;
- case "F":
- total = total + 1.0;
- break;
- case "f":
- total = total + 1.0;
- break;
- default:
- break;
- }
- switch (apclass3)
- {
- case "A":
- total = total + 5.0;
- break;
- case "a":
- total = total + 5.0;
- break;
- case "B":
- total = total + 4.0;
- break;
- case "b":
- total = total + 4.0;
- break;
- case "C":
- total = total + 3.0;
- break;
- case "c":
- total = total + 3.0;
- break;
- case "D":
- total = total + 2.0;
- break;
- case "d":
- total = total + 2.0;
- break;
- case "F":
- total = total + 1.0;
- break;
- case "f":
- total = total + 1.0;
- break;
- default:
- break;
- }
- switch (apclass4)
- {
- case "A":
- total = total + 5.0;
- break;
- case "a":
- total = total + 5.0;
- break;
- case "B":
- total = total + 4.0;
- break;
- case "b":
- total = total + 4.0;
- break;
- case "C":
- total = total + 3.0;
- break;
- case "c":
- total = total + 3.0;
- break;
- case "D":
- total = total + 2.0;
- break;
- case "d":
- total = total + 2.0;
- break;
- case "F":
- total = total + 1.0;
- break;
- case "f":
- total = total + 1.0;
- break;
- default:
- break;
- }
- #endregion
- return total;
- }
- #endregion
- #region money
- static void moneyCalculate()
- {
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine("Money Calculator Initialized");
- Console.WriteLine("=======================================");
- Console.WriteLine("This is calculated using the following format");
- Console.WriteLine("Report Card Grades:");
- Console.WriteLine("Each A | $10");
- Console.WriteLine("Each B | $5");
- Console.WriteLine("Each C | $0");
- Console.WriteLine("Each D | -$5");
- Console.WriteLine("Each F | -20");
- Console.WriteLine("Assignment Grades:");
- Console.WriteLine("Each A | $.50");
- Console.WriteLine("Each B | $.25");
- Console.WriteLine("Each C | $0");
- Console.WriteLine("Each D | -$.25");
- Console.WriteLine("Each F | -$1");
- Console.WriteLine("=======================================");
- Console.WriteLine("Currently Only Supports a single reporting quarter.");
- Console.WriteLine("=======================================");
- Console.WriteLine();
- getRCard();
- getAssignGrade();
- double rCard = calcRCard();
- double aGrade = calcAssignGrade();
- double total = rCard + aGrade;
- double divtotal1 = rCard / 2;
- double divtotal2 = divtotal1 + aGrade;
- Console.WriteLine("=======================================");
- Console.WriteLine("Your money has been Calculated!");
- Console.WriteLine("=======================================");
- Console.WriteLine("Your total ammount is: ${0}", total);
- Console.WriteLine("You will recieve ${0} in cash", divtotal2);
- Console.WriteLine("${0} will be going into your Savings account", divtotal1);
- Console.WriteLine("${0} will be coming from Report card grades", rCard);
- Console.WriteLine("${0} will be coming from Assignment Grades", aGrade);
- Console.WriteLine("=======================================");
- Console.WriteLine();
- Console.WriteLine("Press any key to return to the menu.");
- Console.ReadKey();
- Process();
- }
- static void getRCard()
- {
- Console.WriteLine("=======================================");
- Console.WriteLine("Enter report card grades when prompted.");
- Console.WriteLine("=======================================");
- Console.WriteLine("Enter first letter grade");
- rgrade1 = Console.ReadLine();
- Console.WriteLine("Enter second letter grade");
- rgrade2 = Console.ReadLine();
- Console.WriteLine("Enter third letter grade");
- rgrade3 = Console.ReadLine();
- Console.WriteLine("Enter fourth letter grade");
- rgrade4 = Console.ReadLine();
- Console.WriteLine("=======================================");
- Console.WriteLine();
- rgrade1 = rgrade1.ToUpper();
- rgrade2 = rgrade2.ToUpper();
- rgrade3 = rgrade3.ToUpper();
- rgrade4 = rgrade4.ToUpper();
- }
- static void getAssignGrade()
- {
- Console.WriteLine("=======================================");
- Console.WriteLine("Enter assignment grades when prompted.");
- Console.WriteLine("=======================================");
- Console.WriteLine("Enter the number of A's you recieved");
- agrade = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter the number of B's you recieved");
- bgrade = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter the number of C's you recieved");
- cgrade = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter the number of D's you recieved");
- dgrade = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter the number of F's you recieved");
- fgrade = int.Parse(Console.ReadLine());
- }
- static double calcRCard()
- {
- double total = 0.0;
- switch (rgrade1)
- {
- case "A":
- total = total + 10.0;
- break;
- case "B":
- total = total + 5.0;
- break;
- case "C":
- total = total + 0.0;
- break;
- case "D":
- total = total - 5.0;
- break;
- case "F":
- total = total - 20.0;
- break;
- }
- switch (rgrade2)
- {
- case "A":
- total = total + 10.0;
- break;
- case "B":
- total = total + 5.0;
- break;
- case "C":
- total = total + 0.0;
- break;
- case "D":
- total = total - 5.0;
- break;
- case "F":
- total = total - 20.0;
- break;
- }
- switch (rgrade3)
- {
- case "A":
- total = total + 10.0;
- break;
- case "B":
- total = total + 5.0;
- break;
- case "C":
- total = total + 0.0;
- break;
- case "D":
- total = total - 5.0;
- break;
- case "F":
- total = total - 20.0;
- break;
- }
- switch (rgrade4)
- {
- case "A":
- total = total + 10.0;
- break;
- case "B":
- total = total + 5.0;
- break;
- case "C":
- total = total + 0.0;
- break;
- case "D":
- total = total - 5.0;
- break;
- case "F":
- total = total - 20.0;
- break;
- }
- return total;
- }
- static double calcAssignGrade()
- {
- double total = 0.0;
- double atotal = agrade * 0.5;
- double btotal = bgrade * 0.25;
- double ctotal = 0.0;
- double dtotal = dgrade * 5.0;
- dtotal = dtotal * -1;
- double ftotal = fgrade * 20.0;
- ftotal = ftotal * -1;
- total = atotal + btotal + ctotal + dtotal + ftotal;
- return total;
- }
- #endregion
- #region other
- static void consoleNoClose()
- {
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine("Press Any Key to Exit . . .");
- Console.ReadKey();
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement