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;
- /*Assignment: Project #2*/
- /*Name: Ruei-Chi Lai*****/
- /*Date:3-1-2020**********/
- namespace Project2
- {
- class Program
- {
- static void Main(string[] args)
- {
- //variables
- string sName = string.Empty;
- bool answer = false;
- string className = string.Empty;
- int credithours = 0;
- int totalcredithours = 0;
- int totalpoints = 0;
- Double GPA = 0.00;
- int totalpointsclasses = 0;
- char points = ' ';
- //Execution
- Console.WriteLine("What is your name?");
- sName = Console.ReadLine();
- try
- {
- while(answer == false)
- {
- Console.WriteLine("Please enter the name of the class: ");
- className = Console.ReadLine();
- Console.WriteLine("Please enter the letter grade for the test:");
- char input = char.Parse(Console.ReadLine());
- input = points;
- switch (points)
- {
- case 'A': totalpoints += 4;
- break;
- case 'B': totalpoints += 3;
- break;
- case 'C': totalpoints += 2;
- break;
- case 'D': totalpoints += 1;
- break;
- case 'F': totalpoints += 0;
- break;
- }
- totalpointsclasses = totalpoints * credithours;
- GPA = totalpointsclasses / totalcredithours;
- Console.WriteLine("Please enter the amount of credit hours:");
- credithours = int.Parse(Console.ReadLine());
- totalcredithours += credithours;
- Console.WriteLine("Are you finished? <yes or no>");
- if(Console.ReadLine() == "yes")
- {
- answer = true;
- }
- }
- //Display total credit hours
- Console.WriteLine(sName + ", your GPA is: {0.00} ", GPA);
- Console.ReadLine();
- }
- catch (System.Exception e)
- {
- Console.WriteLine("An error has occured");
- Console.WriteLine("The error was {0}", e.Message);
- Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement