Advertisement
Guest User

Untitled

a guest
Jul 12th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Grades
  5. {
  6. public static void main(String[] args)
  7. {
  8.  
  9. int score1, score2, score3, score4, score5;
  10. int average;
  11. String grade;
  12.  
  13.  
  14. Scanner input = new Scanner(System.in);
  15.  
  16. System.out.println("Enter the "
  17. + "first score:");
  18. score1 = input.nextInt();
  19.  
  20.  
  21. System.out.println("Enter the "
  22. + "second score:");
  23. score2 = input.nextInt();
  24.  
  25.  
  26. System.out.println("Enter the "
  27. + "third score:");
  28. score3 = input.nextInt();
  29.  
  30.  
  31. System.out.println("Enter the "
  32. + "fourth score:");
  33. score4 = input.nextInt();
  34.  
  35.  
  36. System.out.println("Enter the "
  37. + "fifth score:");
  38. score5 = input.nextInt();
  39.  
  40. average = (int)calcAverage(score1, score2, score3, score4, score5);
  41. System.out.println(average);
  42. System.out.println(grade);
  43. }
  44.  
  45.  
  46.  
  47. public static double calcAverage(int score1, int score2, int score3, int score4, int score5)
  48. {
  49. return ((score1 + score2 + score3 + score4 + score5) / 5);
  50. }
  51.  
  52. public static double determineGrade(int average, char grade)
  53. {
  54. if (average > 90f)
  55. grade = 'A';
  56. }
  57. {
  58. if (average > 80f &
  59. average < 90f)
  60. grade = 'B';
  61. }
  62. {
  63. if (average > 70f &
  64. average < 80f)
  65. grade = 'C';
  66. }
  67. {
  68. if (average > 60f &
  69. average < 70f)
  70. grade = 'D';
  71. }
  72. {
  73. if (average < 60f)
  74. grade = 'F';
  75. }
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement