Advertisement
zainarfi00

Chapter 4 Projects

Oct 24th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.99 KB | None | 0 0
  1.  
  2. /**
  3. * Project 2
  4. *
  5. * Z@in @rfi
  6. * October 22 2015
  7. */
  8. import java.util.*;
  9. public class Project2
  10. {
  11. public static void main(String[] args)
  12. {
  13. Scanner console = new Scanner(System.in);
  14. System.out.println("What is the GPA of Applicant 1?");
  15. double GPA1 = console.nextDouble();
  16. System.out.println("What is the ACT score of Applicant 1?");
  17. double ACT1 = console.nextDouble();
  18. System.out.println("What is the SAT score of Applicant 1?");
  19. double SAT1 = console.nextDouble();
  20. System.out.println("What is the GPA of Applicant 2?");
  21. double GPA2 = console.nextDouble();
  22. System.out.println("What is the ACT score of Applicant 2?");
  23. double ACT2 = console.nextDouble();
  24. System.out.println("What is the SAT score of Applicant 2?");
  25. double SAT2 = console.nextDouble();
  26. Acceptance(GPA1, ACT1, SAT1, GPA2, ACT2, SAT2);
  27. }
  28. public static void Acceptance(double gpa1, double act1, double sat1, double gpa2, double act2, double sat2)
  29. {
  30. int a = 0;
  31. int b = 0;
  32. if(gpa1 > gpa2)
  33. {
  34. a = 1;
  35. }
  36. else if(gpa2 < gpa1)
  37. {
  38. b = 1;
  39. }
  40. else
  41. {
  42. a = 0;
  43. b = 0;
  44. }
  45. if(act1 > act2)
  46. {
  47. a = a + 1;
  48. }
  49. else if(act1 < act2)
  50. {
  51. b = b + 1;
  52. }
  53. else
  54. {
  55. a = a + 0;
  56. b = b + 0;
  57. }
  58. if(sat1 > sat2)
  59. {
  60. a = a + 1;
  61. }
  62. else if(sat1 < sat2)
  63. {
  64. b = b + 1;
  65. }
  66. else
  67. {
  68. a = a + 0;
  69. b = b + 0;
  70. }
  71. if( a > b)
  72. {
  73. System.out.println("Applicant 1 is more qualified!");
  74. }
  75. else if( a < b)
  76. {
  77. System.out.println("Applicant 2 is more qualified!");
  78. }
  79. else
  80. {
  81. System.out.println("Applicant 1 and Applicant 2 are equally qualified!");
  82. }
  83. }
  84. }
  85.  
  86.  
  87.  
  88.  
  89. /**
  90. * Project 2
  91. *
  92. * Z@in @rfi
  93. * September 23
  94. */
  95. import java.util.*;
  96. public class Project4
  97. {
  98. public static void main(String[] args)
  99. {
  100. Scanner console = new Scanner(System.in);
  101. System.out.println("What is the month of your birthday in numbers?");
  102. int month1 = console.nextInt();
  103. System.out.println("What is the day of your birthday?");
  104. int day1 = console.nextInt();
  105. System.out.println("What is the month of the other person's birthday in numbers?");
  106. int month2 = console.nextInt();
  107. System.out.println("What is the day of person two's birthday?");
  108. int day2 = console.nextInt();
  109. Calculate(month1, day1, month2, day2);
  110. }
  111. public static void Calculate(int m1, int d1, int m2, int d2)
  112. {
  113. int absoday1 = 0;
  114. int absoday2 = 0;
  115. if( m1 == 1)
  116. {
  117. absoday1 = 0;
  118. }
  119. else if( m2 == 1)
  120. {
  121. absoday2 = 0;
  122. }
  123. else if( m1 == 2)
  124. {
  125. absoday1 = 31;
  126. }
  127. else if( m1 == 3)
  128. {
  129. absoday1 = 59;
  130. }
  131. else if( m1 == 4)
  132. {
  133. absoday1 = 90;
  134. }
  135. else if( m1 == 5)
  136. {
  137. absoday1 = 120;
  138. }
  139. else if( m1 == 6)
  140. {
  141. absoday1 = 151;
  142. }
  143. else if( m1 == 7)
  144. {
  145. absoday1 = 181;
  146. }
  147. else if( m1 == 8)
  148. {
  149. absoday1 = 212;
  150. }
  151. else if( m1 == 9)
  152. {
  153. absoday1 = 243;
  154. }
  155. else if( m1 == 10)
  156. {
  157. absoday1 = 273;
  158. }
  159. else if( m1 == 11)
  160. {
  161. absoday1 = 304;
  162. }
  163. else if(m1 == 12)
  164. {
  165. absoday1 = 334;
  166. }
  167.  
  168. else if( m2 == 2)
  169. {
  170. absoday2 = 31;
  171. }
  172. else if( m2 == 3)
  173. {
  174. absoday2 = 59;
  175. }
  176. else if( m2 == 4)
  177. {
  178. absoday2 = 90;
  179. }
  180. else if( m2 == 5)
  181. {
  182. absoday2 = 120;
  183. }
  184. else if( m2 == 6)
  185. {
  186. absoday2 = 151;
  187. }
  188. else if( m2 == 7)
  189. {
  190. absoday2 = 181;
  191. }
  192. else if( m2 == 8)
  193. {
  194. absoday2 = 212;
  195. }
  196. else if( m2 == 9)
  197. {
  198. absoday2 = 243;
  199. }
  200. else if( m2 == 10)
  201. {
  202. absoday2 = 273;
  203. }
  204. else if( m2 == 11)
  205. {
  206. absoday2 = 304;
  207. }
  208. else if(m2 == 12)
  209. {
  210. absoday2 = 334;
  211. }
  212. else
  213. {
  214. absoday1 = 0;
  215. }
  216. if( m1 > m2)
  217. {
  218. System.out.println("Person 2's Birthday is sooner!");
  219. int diff = (absoday1 + d1) - (absoday2 + d2);
  220. System.out.println(diff + " days until Person 1's Birthday!");
  221. }
  222. else if( m1 < m2)
  223. {
  224. System.out.println("Person 1's Birthday is sooner!");
  225. int diff = (absoday2 + d2) - (absoday1 +d2);
  226. System.out.println(diff + " days until Person 2's Birthday!");
  227. }
  228. else if( m1 == m2 && d1 != d2)
  229. {
  230. if( d1 > d2)
  231. {
  232. System.out.println("Person 2's Birthday is sooner!");
  233. int diff = d1 - d2;
  234. System.out.println(diff +" days until Person 1's Birthday!");
  235. }
  236. else if( d1 < d2)
  237. {
  238. System.out.println("Person 1's Birthday is sooner!");
  239. int diff = d2 - d1;
  240. System.out.println(diff + " days until Person 2's Birthday!");
  241. }
  242. }
  243. else
  244. {
  245. System.out.println("Y'all have the same birthday!");
  246. }
  247. }
  248. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement