willieshi232

Untitled

Oct 27th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.17 KB | None | 0 0
  1. 3.import java.util.*;
  2. public class Project3
  3. {
  4. public static void main(String [] args)
  5. {
  6. Scanner pikachu = new Scanner(System.in);
  7. System.out.print("Input information for Student #1");
  8. System.out.print("GPA:");
  9. double GPA1 = pikachu.nextDouble();
  10. System.out.print("SAT:");
  11. int SAT1 = pikachu.nextInt();
  12. if(SAT1 > 2400 || SAT1 < 600)
  13. {
  14. System.out.print("THAT IS AN INVALID SCORE");
  15. }
  16. System.out.print("ACT:");
  17. int ACT1 = pikachu.nextInt();
  18. if(ACT1 > 36 || ACT1 < 1)
  19. {
  20. System.out.print("THAT IS AN INVALID SCORE");
  21. }
  22. System.out.print("Input information for student #2");
  23. System.out.print("GPA:");
  24. double GPA2 = pikachu.nextDouble();
  25. System.out.print("SAT:");
  26. int SAT2 = pikachu.nextInt();
  27. if(SAT2 > 2400 || SAT1 < 600)
  28. {
  29. System.out.print("THAT IS AN INVALID SCORE");
  30. }
  31. System.out.print("ACT");
  32. int ACT2 = pikachu.nextInt();
  33. if(ACT2 > 36 || ACT1 < 1)
  34. {
  35. System.out.print("THAT IS AN INVALID SCORE");
  36. }
  37. double LargerScore1 = Compare1(SAT1, ACT1);
  38. double LargerScore2 = Compare2(SAT2, ACT2);
  39.  
  40. double BetterStudent = Calculation(LargerScore1, LargerScore2, GPA1, GPA2);
  41. if(BetterStudent == LargerScore1+GPA1)
  42. {
  43. System.out.print("Student#1 is more qualified for this school");
  44. }
  45. else if(BetterStudent == LargerScore2+GPA2)
  46. {
  47. System.out.print("Student#2 is more qualified for this school");
  48. }
  49. else
  50. {
  51. System.out.print("Both Students are equally qualified");
  52. }
  53. // Program to compare the ratios between the student's SAT and ACT Score and send the bigger percentage
  54. }
  55. // Method to compare the ratios between the student#1's SAT and ACT Score and send the bigger percentage
  56. public static double Compare1(int SAT1, int ACT1)
  57. {
  58. double SATRatio1 = SAT1/2400;
  59. double ACTRatio1 = ACT1/36;
  60. if(SATRatio1 > ACTRatio1)
  61. {
  62. return SATRatio1;
  63. }
  64. else if(ACTRatio1 > SATRatio1)
  65. {
  66. return ACTRatio1;
  67. }
  68. //If the student recieved perfect scores for both then the method will return the ACT score.
  69. else
  70. {
  71. return ACTRatio1;
  72. }
  73. }
  74. // Method to compare the ratios between the student#2's SAT and ACT Score and send the bigger percentage
  75. public static double Compare2(int SAT2, int ACT2)
  76. {
  77. double SATRatio2 = SAT2/2400;
  78. double ACTRatio2 = ACT2/36;
  79. if(SATRatio2 > ACTRatio2)
  80. {
  81. return SATRatio2;
  82. }
  83. else if(ACTRatio2 > SATRatio2)
  84. {
  85. return ACTRatio2;
  86. }
  87. //If the student recieved perfect scores for both then the method will return the ACT score.
  88. else
  89. {
  90. return ACTRatio2;
  91. }
  92. }
  93. // Method to Calculate the larger Student Score
  94. public static double Calculation(double LargerScore1, double LargerScore2, double GPA1, double GPA2)
  95. {
  96. double Student1 = GPA1+LargerScore1;
  97. double Student2 = GPA2+LargerScore2;
  98. double equality = 0.0;
  99. if(Student1 > Student2)
  100. {
  101. return Student1;
  102. }
  103. else if(Student1 < Student2)
  104. {
  105. return Student2;
  106. }
  107. // If the students score's are equal
  108. else
  109. {
  110. return equality;
  111. }
  112. }
  113. }
  114. 4. import java.util.*;
  115. public class Project4
  116. {
  117. public static void main(String [] args)
  118. {
  119. Scanner pikachu = new Scanner(System.in);
  120. System.out.println("What is the current date");
  121. System.out.print("Numerical value for Month:");
  122. int Month1 = pikachu.nextInt();
  123. System.out.print("Day:");
  124. int Day1 = pikachu.nextInt();
  125. System.out.print("Input the Birthday for person #1");
  126. System.out.print("Numerical value for Month:");
  127. int Month2 = pikachu.nextInt();
  128. System.out.print("Day:");
  129. int Day2 = pikachu.nextInt();
  130. System.out.print("Intput the Birthday for person #2");
  131. System.out.print("Numerical value for Month");
  132. int Month3 = pikachu.nextInt();
  133. System.out.print("Day:");
  134. int Day3 = pikachu.nextInt();
  135. int absvdate1 = Calculation1(Month1, Day1);
  136. int absvdate2 = Calculation2(Month2, Day2);
  137. int absvdate3 = Calculation3(Month3, Day3);
  138. int daystill1 = Math.abs(absvdate2-absvdate1);
  139. int daystill2 = Math.abs(absvdate3-absvdate1);
  140. if(daystill1 > daystill2)
  141. {
  142. System.out.print("User #1 has the later birthdate");
  143. }
  144. else if(daystill2 > daystill1)
  145. {
  146. System.out.print("User #2 has the later birthdate");
  147. }
  148. else
  149. {
  150. System.out.print("Users have the same birthday");
  151. }
  152. System.out.println("Days until User #1 birthday:+"+daystill1);
  153. System.out.println("Days until User #2 birthday:+"+daystill2);
  154. }
  155. public static int Calculation1(int Month1, int Day1)
  156. {
  157. if(Month1 == 2)
  158. {
  159. Month1 = 31;
  160. }
  161. else if(Month1 == 3)
  162. {
  163. Month1 = 59;
  164. }
  165. else if(Month1 == 4)
  166. {
  167. Month1 = 90;
  168. }
  169. else if(Month1 == 5)
  170. {
  171. Month1 = 120;
  172. }
  173. else if(Month1 == 6)
  174. {
  175. Month1 = 151;
  176. }
  177. else if(Month1 == 7)
  178. {
  179. Month1 = 181;
  180. }
  181. else if(Month1 == 8)
  182. {
  183. Month1 = 212;
  184. }
  185. else if(Month1 == 9)
  186. {
  187. Month1 = 243;
  188. }
  189. else if(Month1 == 10)
  190. {
  191. Month1 = 273;
  192. }
  193. else if(Month1 == 11)
  194. {
  195. Month1 = 304;
  196. }
  197. else if(Month1 == 12)
  198. {
  199. Month1 = 334;
  200. }
  201. int absvdate2 = Month1+Day1;
  202. return absvdate2;
  203. }
  204. public static int Calculation2(int Month2, int Day2)
  205. {
  206. if(Month2 == 2)
  207. {
  208. Month2 = 31;
  209. }
  210. else if(Month2 == 3)
  211. {
  212. Month2 = 59;
  213. }
  214. else if(Month2 == 4)
  215. {
  216. Month2 = 90;
  217. }
  218. else if(Month2 == 5)
  219. {
  220. Month2 = 120;
  221. }
  222. else if(Month2 == 6)
  223. {
  224. Month2 = 151;
  225. }
  226. else if(Month2 == 7)
  227. {
  228. Month2 = 181;
  229. }
  230. else if(Month2 == 8)
  231. {
  232. Month2 = 212;
  233. }
  234. else if(Month2 == 9)
  235. {
  236. Month2 = 243;
  237. }
  238. else if(Month2 == 10)
  239. {
  240. Month2 = 273;
  241. }
  242. else if(Month2 == 11)
  243. {
  244. Month2 = 304;
  245. }
  246. else if(Month2 == 12)
  247. {
  248. Month2 = 334;
  249. }
  250. int absvdate2 = Month2+Day2;
  251. return absvdate2;
  252. }
  253. public static int Calculation3(int Month3, int Day3)
  254. {
  255. if(Month3 == 2)
  256. {
  257. Month3 = 31;
  258. }
  259. else if(Month3 == 3)
  260. {
  261. Month3 = 59;
  262. }
  263. else if(Month3 == 4)
  264. {
  265. Month3 = 90;
  266. }
  267. else if(Month3 == 5)
  268. {
  269. Month3 = 120;
  270. }
  271. else if(Month3 == 6)
  272. {
  273. Month3 = 151;
  274. }
  275. else if(Month3 == 7)
  276. {
  277. Month3 = 181;
  278. }
  279. else if(Month3 == 8)
  280. {
  281. Month3 = 212;
  282. }
  283. else if(Month3 == 9)
  284. {
  285. Month3 = 243;
  286. }
  287. else if(Month3 == 10)
  288. {
  289. Month3 = 273;
  290. }
  291. else if(Month3 == 11)
  292. {
  293. Month3 = 304;
  294. }
  295. else if(Month3 == 12)
  296. {
  297. Month3 = 334;
  298. }
  299. int absvdate3 = Month3+Day3;
  300. return absvdate3;
  301. }
  302. }
Advertisement
Add Comment
Please, Sign In to add comment