Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 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.  
  8. /*Assignment: Project #2*/
  9. /*Name: Ruei-Chi Lai*****/
  10. /*Date:3-1-2020**********/
  11.  
  12.  
  13. namespace Project2
  14. {
  15. class Program
  16. {
  17. static void Main(string[] args)
  18. {
  19. //variables
  20. string sName = string.Empty;
  21. bool answer = false;
  22. string className = string.Empty;
  23. int credithours = 0;
  24. int totalcredithours = 0;
  25. int totalpoints = 0;
  26. Double GPA = 0.00;
  27. int totalpointsclasses = 0;
  28. char points = ' ';
  29. //Execution
  30. Console.WriteLine("What is your name?");
  31. sName = Console.ReadLine();
  32.  
  33. try
  34. {
  35. while(answer == false)
  36. {
  37. Console.WriteLine("Please enter the name of the class: ");
  38. className = Console.ReadLine();
  39.  
  40. Console.WriteLine("Please enter the letter grade for the test:");
  41. char input = char.Parse(Console.ReadLine());
  42. input = points;
  43. switch (points)
  44. {
  45. case 'A': totalpoints += 4;
  46. break;
  47. case 'B': totalpoints += 3;
  48. break;
  49. case 'C': totalpoints += 2;
  50. break;
  51. case 'D': totalpoints += 1;
  52. break;
  53. case 'F': totalpoints += 0;
  54. break;
  55. }
  56.  
  57. totalpointsclasses = totalpoints * credithours;
  58. GPA = totalpointsclasses / totalcredithours;
  59.  
  60.  
  61. Console.WriteLine("Please enter the amount of credit hours:");
  62. credithours = int.Parse(Console.ReadLine());
  63. totalcredithours += credithours;
  64.  
  65. Console.WriteLine("Are you finished? <yes or no>");
  66. if(Console.ReadLine() == "yes")
  67. {
  68. answer = true;
  69. }
  70.  
  71.  
  72.  
  73.  
  74. }
  75. //Display total credit hours
  76. Console.WriteLine(sName + ", your GPA is: {0.00} ", GPA);
  77. Console.ReadLine();
  78.  
  79.  
  80.  
  81. }
  82. catch (System.Exception e)
  83. {
  84. Console.WriteLine("An error has occured");
  85. Console.WriteLine("The error was {0}", e.Message);
  86. Console.ReadLine();
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94. }
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement