SHARE
TWEET

Untitled

a guest Sep 20th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package practise;
  2. import java.util.Scanner;
  3.  
  4. public class CGPACalculator {
  5.  
  6.     public static void main(String[] args) {
  7.         // TODO Auto-generated method stub
  8. // DATA 1 - CREDIT HOURS
  9. // DATA 2 - GRADE VALUE
  10. //
  11. // --------- Initialize all calculators --------- //
  12. double credit_hours1 = 0;
  13. double credit_hours2 = 0;
  14. double credit_hours3 = 0;
  15. double credit_hours4 = 0;
  16. double credit_hours5 = 0;
  17. double credit_hours6 = 0;
  18. double credit_hours7 = 0;
  19. double credit_hours8 = 0;
  20. double credit_hours9 = 0;
  21. System.out.println("Calculator has been initialized.");
  22.  
  23. // ----------- Declare sub1 - sub9 ------------ //
  24. double sub1 ;
  25. double sub2 ;
  26. double sub3 ;
  27. double sub4 ;
  28. double sub5 ;
  29. double sub6 ;
  30. double sub7 ;
  31. double sub8 ;
  32. double sub9 ;
  33.  
  34. // --------- Declare grade1 - grade 9 ---------- //
  35. int grade1 = 0;
  36. int grade2 = 0;
  37. int grade3 = 0;
  38. int grade4 = 0;
  39. int grade5 = 0;
  40. int grade6 = 0;
  41. int grade7 = 0;
  42. int grade8 = 0;
  43. int grade9 = 0;
  44. System.out.println("Grades have been declared within each subject.");
  45.  
  46. // -------- Declare LCA --------- //
  47.  
  48. char a; // A
  49. char b; // A-
  50. char c; // B+
  51. char d; // B
  52. char e; // B-
  53. char f; // C+
  54. char g; // C
  55. char h; // C-
  56. char i; // D+
  57. char j; // D
  58. char k; // F
  59. System.out.println("Grades have been declared.");
  60.  
  61. //-------- Preset LCA to grades ---------- //
  62.  
  63. a = 'A' ;
  64. b = 'B' ;
  65. c = 'C' ;
  66. d = 'D' ;
  67. e = 'E' ;
  68. f = 'F' ;
  69. g = 'G' ;
  70. h = 'H' ;
  71. i = 'I' ;
  72. j = 'J' ;
  73. k = 'K' ;
  74. System.out.println("LCA Grades have been preset.");
  75.  
  76. // -------- Assign Grade to Value ---------- //
  77.  
  78. final double A = 4.00 ;
  79. final double B = 3.67 ;
  80. final double C = 3.33 ;
  81. final double D = 3.00 ;
  82. final double E = 2.67 ;
  83. final double F = 2.33 ;
  84. final double G = 2.00 ;
  85. final double H = 1.67 ;
  86. final double I = 1.33 ;
  87. final double J = 1.00 ;
  88. final double K = 0.00 ;
  89. System.out.println("Grade value has been loaded.");
  90.  
  91. // --------- Insertion of data for Credit Hours --------- //
  92.  
  93. Scanner scanner = new Scanner(System.in);
  94. System.out.println("Enter credit hours for subject : Engineering Drawing ... ");
  95. credit_hours1 = scanner.nextDouble();
  96. System.out.println("Enter grade achieved");
  97. grade1 = scanner.next().charAt(0);
  98. System.out.println("Enter credit hours for subject : Engineering Science ... ");
  99. credit_hours2 = scanner.nextDouble();
  100. System.out.println("Enter grade achieved");
  101. grade2 = scanner.next().charAt(0);
  102. System.out.println("Enter credit hours for subject : Workshop Practices ... ");
  103. credit_hours3 = scanner.nextDouble();
  104. System.out.println("Enter grade achieved");
  105. grade3 = scanner.next().charAt(0);
  106. System.out.println("Enter credit hours for subject : Conventional Turning ... ");
  107. credit_hours4 = scanner.nextDouble();
  108. System.out.println("Enter grade achieved");
  109. grade4 = scanner.next().charAt(0);
  110. System.out.println("Enter credit hours for subject : Engineering Meteorology ... ");
  111. credit_hours5 = scanner.nextDouble();
  112. System.out.println("Enter grade achieved");
  113. grade5 = scanner.next().charAt(0);
  114. System.out.println("Enter credit hours for subject : English for Communication 1 ... ");
  115. credit_hours6 = scanner.nextDouble();
  116. System.out.println("Enter grade achieved");
  117. grade6 = scanner.next().charAt(0);
  118. System.out.println("Enter credit hours for subject : Engineering Mathematics 1 ... ");
  119. credit_hours7 = scanner.nextDouble();
  120. System.out.println("Enter grade achieved");
  121. grade7 = scanner.next().charAt(0);
  122. System.out.println("Enter credit hours for subject : Perspektif Islam ... ");
  123. credit_hours8 = scanner.nextDouble();
  124. System.out.println("Enter grade achieved");
  125. grade8 = scanner.next().charAt(0);
  126. System.out.println("Enter credit hours for subject : Co-Curriculum 1 ... ");
  127. credit_hours9 = scanner.nextDouble();
  128. System.out.println("Enter grade achieved");
  129. grade9 = scanner.next().charAt(0);
  130.  
  131. sub1 = credit_hours1 * grade1;
  132. sub2 = credit_hours2 * grade2;
  133. sub3 = credit_hours3 * grade3;
  134. sub4 = credit_hours4 * grade4;
  135. sub5 = credit_hours5 * grade5;
  136. sub6 = credit_hours6 * grade6;
  137. sub7 = credit_hours7 * grade7;
  138. sub8 = credit_hours8 * grade8;
  139. sub9 = credit_hours9 * grade9;
  140.  
  141. // ------- Declare grand total ------- //
  142. double subs;
  143. double totalch;
  144. double pointer;
  145. subs = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9;
  146. totalch = credit_hours1 + credit_hours2 + credit_hours3 + credit_hours4 + credit_hours5 + credit_hours6 + credit_hours7 + credit_hours8 + credit_hours9;
  147. pointer = subs / totalch ;
  148.  
  149. System.out.printf("Pointer is %.2f .", pointer);
  150.     }
  151.  
  152. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top