Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EvenOddDigits
  4. {
  5. public static void main(String [] args){
  6. giveIntro();
  7. Scanner console = new Scanner(System.in);
  8. double studentOneExam = getExamScore(console);
  9. double studentOneGPA = getGPA(console);
  10. double studentTwoExam = getExamScore(console);
  11. double studentTwoGPA = getGPA(console);
  12. double studentOneTotal = total(studentOneExam, studentOneGPA);
  13. double studentTwoTotal = total(studentTwoExam, studentTwoGPA);
  14. compareApplicants(studentOneTotal, studentTwoTotal);
  15.  
  16.  
  17. }
  18.  
  19. // Introduces the program to the user
  20. public static void giveIntro(){
  21. System.out.println("This program compares two applicants to");
  22. System.out.println("determine which one seems like the stronger");
  23. System.out.println("applicant. For each candidate I will need");
  24. System.out.println("either SAT or ACT scores plus a weighted GPA.");
  25. System.out.println();
  26. }
  27.  
  28. // Uses the console scanner to prompt for the person's statistics
  29. // Returns the exam scores
  30. public static double getExamScore(Scanner console) {
  31. System.out.println("Information for applicant #1:");
  32. System.out.print("do you have 1) SAT scores or 2) ACT scores? ");
  33. int choice;
  34. choice = console.nextInt();
  35. double score = 0.0;
  36. if (choice == 1){
  37. score = getSATInfo(console);
  38. }
  39. if (choice == 2){
  40. score = getACTInfo(console);
  41. }
  42. return score; // fix the return variable this is the problem
  43. }
  44.  
  45. // Uses the console scanner to prompt for SAT information
  46. public static double getSATInfo(Scanner console) {
  47. System.out.print("SAT math? ");
  48. double math = console.nextInt();
  49. System.out.print("SAT critical reading? ");
  50. double reading = console.nextInt();
  51. System.out.print("SAT writing? ");
  52. double writing = console.nextInt();
  53. double score = SATScore(math, reading, writing);
  54. System.out.println("exam score = " + round(score));
  55. return score;
  56. }
  57.  
  58. // returns the overall SAT exam score given math, reading, and writing scores
  59. // out of 100
  60. public static double SATScore (double math, double reading, double writing) {
  61. return (2 * math + reading + writing)/32;
  62. }
  63.  
  64. // Uses the console scanner to prompt for ACT information
  65. public static double getACTInfo(Scanner console) {
  66. System.out.print("ACT English? ");
  67. double English = console.nextInt();
  68. System.out.print("ACT math? ");
  69. double math = console.nextInt();
  70. System.out.print("ACT reading? ");
  71. double reading = console.nextInt();
  72. System.out.print("ACT science? ");
  73. double science = console.nextInt();
  74. double score = ACTScore(English, math, reading, science);
  75. System.out.println("exam score = " + round(score));
  76. return score;
  77. }
  78.  
  79. // returns the overall ACT exam score given English, math, reading, and
  80. // science scores out of 100
  81. public static double ACTScore (double English, double math,
  82. double reading, double science) {
  83. return (English + 2*math + reading + science)/1.8;
  84. }
  85.  
  86. // Returns the overall score of the GPA given actual, max, and transcript multiplier
  87. // also out of 100
  88. public static double getGPA(Scanner console){
  89. System.out.print("overall GPA? ");
  90. double actualGPA = console.nextDouble();
  91. System.out.print("max GPA? ");
  92. double maxGPA = console.nextDouble();
  93. System.out.print("Transcript Multiplier? ");
  94. double multiplier = console.nextDouble();
  95. double score = GPAScore(actualGPA, maxGPA, multiplier);
  96. System.out.print("GPA score = " + round(score));
  97. System.out.println();
  98. return score;
  99. }
  100. public static void compareApplicants(double studentOne, double studentTwo){
  101. System.out.println("First applicant overall score = " +Math.round(studentOne*10.0)/10.0);
  102. System.out.println("Second applicant overall score = " +Math.round(studentTwo*10.0)/10.0);
  103.  
  104. if(studentOne > studentTwo)
  105. System.out.print("The first applicant seems to be better");
  106. else
  107. System.out.print("The second applicant seems to be better");
  108.  
  109.  
  110. }
  111. // calculates the GPA score separately for the getGPA method
  112. public static double GPAScore (double actualGPA, double maxGPA, double multiplier){
  113. return (actualGPA/maxGPA)*100*multiplier;
  114. }
  115.  
  116. // sounds the GPA and ACT scores to one decimal place
  117. public static double round(double n) {
  118. return Math.round(n * 10.0) / 10.0;
  119. }
  120.  
  121. public static double total(double studentExam, double studentGPA){
  122. return studentExam + studentGPA;
  123. }
  124.  
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement