Advertisement
Guest User

assignment 4 prblm 3

a guest
Oct 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. 3.
  2. import java.util.Scanner;
  3. public class Main {
  4. static final double QUIZ_WEIGHT = .10; // Counts for 10% of the final grade
  5. static final double HW_WEIGHT = .15; // Counts for 15% of the final grade
  6. static final double TEST_WEIGHT = .75; // Counts for 75% of the final grade
  7. private static Scanner in;
  8.  
  9. public static void main(String[] args) {
  10. double test1, test2, test3, quizAvg, hwAvg;
  11.  
  12. in = new Scanner(System.in);
  13. System.out.println("This program will compute your GPA");
  14. System.out.print("Enter your Quiz average: ");
  15. quizAvg = in.nextDouble();
  16. System.out.print("Enter your Homework average: ");
  17. hwAvg = in.nextDouble();
  18. System.out.print("Enter your score for Test 1: ");
  19. test1 = in.nextDouble();
  20. System.out.print("Enter your score for Test 2: ");
  21. test2 = in.nextDouble();
  22. System.out.print("Enter your score for Test 3: ");
  23. test3 = in.nextDouble();
  24.  
  25.  
  26. //Displays Tests
  27. System.out.println("High Test: " + highestTest(test1, test2, test3));
  28. System.out.println("Low Test: " + lowestTest(test1, test2, test3));
  29. System.out.println("Average Test: " + averageTest(test1, test2,test3));
  30.  
  31. //Displays GPA
  32. System.out.println("GPA: " + getGPA(test1, test2, test3, quizAvg, hwAvg));
  33. }
  34. //Method : Returns GPA
  35. public static double getGPA(double t1, double t2, double t3, double q, double h) {
  36. double weightTest = (t1 + t2 + t3)/3.0 * TEST_WEIGHT;
  37. double weightQuiz = q * QUIZ_WEIGHT;
  38. double weightHW = h * HW_WEIGHT;
  39. return weightTest + weightQuiz + weightHW;
  40. }
  41.  
  42.  
  43. //Method: Returns The Average Test Score
  44. public static double averageTest(double test1, double test2, double test3) {
  45. return (test1 + test2 + test3)/3.0;
  46. }
  47.  
  48. //Method: Returns The Highest Test Score
  49. public static double highestTest(double test1, double test2, double test3) {
  50. if (test1 >= test2 && test1 >= test3)
  51. return test1;
  52. else if (test2 >= test1 && test2 >= test3)
  53. return test2;
  54. else
  55. return test3;
  56. }
  57.  
  58. //Method: Returns The Lowest Test Score
  59. public static double lowestTest(double test1, double test2, double test3) {
  60. if (test1 <= test2 && test1 <= test3)
  61. return test1;
  62. else if (test2 <= test1 && test2 <= test3)
  63. return test2;
  64. else
  65. return test3;
  66.  
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement