Guest User

Untitled

a guest
Feb 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3. public class scores {
  4.  
  5. public static void main(String[] args) {
  6.  
  7.  
  8. double[] scores = new double[30];
  9. double[] credithour = new double[30];
  10. double total = 0;
  11. int register;
  12. double gpa;
  13.  
  14. String[] course = new String[30];
  15.  
  16. System.out.print(" how many courses did you register ? : ");
  17.  
  18. Scanner input4 = new Scanner(System.in) ;
  19.  
  20. register = input4.nextInt();
  21.  
  22.  
  23. if (register > 2 && register < 18){
  24.  
  25. System.out.println (" You registered "+register+" courses !!!");
  26. Scanner input = new Scanner(System.in);
  27.  
  28. System.out.println("Please enter " + register + " course names :::"+"\t");
  29.  
  30. for (int i = 0; i<register; i++){
  31.  
  32. System.out.print (" Enter course " + (i+1) + ":");
  33. course[i] = input.nextLine();
  34.  
  35.  
  36. }
  37. System.out.println("Thank you ");
  38.  
  39. System.out.println (" Now please enter the scores for each course !!!");
  40.  
  41.  
  42.  
  43. for (int i = 0; i< register; i++) {
  44.  
  45. System.out.println (" Enter score for " + course[i] + ":");
  46.  
  47.  
  48. scores[i] = input.nextInt();
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. }
  56.  
  57. System.out.print (" Now enter their credit values !!!");
  58.  
  59. for (int i = 0; i< register; i++) {
  60. System.out.println (" Enter credit value for " + course[i] + ":");
  61. credithour[i] = input.nextInt();
  62. // System.out.println (" done :");
  63.  
  64. }
  65.  
  66. input.close();
  67. input4.close();
  68. //////
  69. for(int i=0;i<register;i++){
  70. if ( scores[i] >= 90 ){
  71. System.out.println( " Your grade is A " );
  72. scores[i]= 4.0;
  73. System.out.println( scores[i] );
  74. }
  75. else
  76. if ( scores[i] >= 80 ){
  77. System.out.println( " Your grade is B " );
  78. scores[i]= 3.5;}
  79. else
  80. if ( scores[i] >= 70 ){
  81. System.out.println( " Your grade is C " );
  82. scores[i]= 3.0;}
  83. else
  84. if ( scores[i] >= 60 ){
  85. System.out.println( " Your grade is D " );
  86. scores[i]= 2.5;}
  87. else{
  88. System.out.println( " Your grade is F " );
  89. scores[i]= 2.0;
  90. }
  91. }
  92.  
  93.  
  94.  
  95. for (int i=0;i<register;i++){
  96.  
  97. total +=credithour[i]*scores[i];
  98.  
  99. System.out.println (credithour[i]+"hours " + scores[i] + "score");
  100.  
  101. }
  102.  
  103. double cpa = 0;
  104. for (int i=0;i<register;i++){
  105.  
  106. cpa +=credithour[i];
  107.  
  108. }
  109.  
  110. System.out.println (" You total is : " + total);
  111. gpa = total /cpa;
  112.  
  113. System.out.println (" You GPA for this semester is : " + gpa);
  114. System.out.println (" Coursname \t Score \t credithour");
  115.  
  116. for(int i=0;i<register;i++){
  117.  
  118. System.out.println (" " + course[i] + "\t" + " " +scores[i] + "\t" + " " + credithour[i] );
  119.  
  120.  
  121. }
Add Comment
Please, Sign In to add comment