Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.15 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. static Scanner in = new Scanner(System.in);
  6.  
  7. public static void main(String[] args) {
  8.  
  9. menuMethod();
  10.  
  11. }
  12.  
  13. private static void menuMethod() {
  14. int iMenu;
  15.  
  16. do {
  17. System.out.println("Enter the question number you wish to see. and press 6 to exit!");
  18. iMenu = in.nextInt();
  19.  
  20. switch (iMenu) {
  21. case 1:tar1();
  22. break;
  23. case 2:tar2();
  24. break;
  25. case 3:tar3();
  26. break;
  27. case 4:tar4();
  28. break;
  29. case 5:tar5();
  30. break;
  31. case 6:return;
  32. default:System.err.println("You need to enter a number from 1-5!");
  33. break;
  34. }
  35.  
  36. }while(iMenu != 6);
  37. }
  38.  
  39. public static void tar1(){
  40. int iDay;
  41.  
  42. System.out.println("Enter a number from 1-7 to know which day it is");
  43. iDay = in.nextInt();
  44. //finds what day of the week it is
  45.  
  46. switch(iDay){
  47. case 1:System.out.println("Sunday");
  48. break;
  49. case 2:System.out.println("Monday");
  50. break;
  51. case 3:System.out.println("Tuesday");
  52. break;
  53. case 4:System.out.println("Wednesday");
  54. break;
  55. case 5:System.out.println("Thursday");
  56. break;
  57. case 6:System.out.println("Friday");
  58. break;
  59. case 7:System.out.println("Saturday");
  60. break;
  61. default:System.err.println("You need to enter a number from 1-7");
  62.  
  63. }
  64. }
  65.  
  66. public static void tar2(){
  67. int iNum;
  68.  
  69. System.out.println("Enter a number from 1-10");
  70. iNum = in.nextInt();
  71. //finds if number is small medium or large
  72.  
  73. switch(iNum){
  74. case 1:
  75. case 2:
  76. case 3:System.out.println("You entered a Small number");
  77. break;
  78. case 4:
  79. case 5:
  80. case 6:
  81. case 7:System.out.println("You entered a Medium number");
  82. break;
  83. case 8:
  84. case 9:
  85. case 10:System.out.println("You entered a Large number");
  86. break;
  87. default:System.err.println("You need to enter a number from 1-10");
  88. }
  89. }
  90.  
  91. public static void tar3(){
  92. char cLetter;
  93.  
  94. System.out.println("הכנס את האות הראשונה של שם המשפחה של ילדכם");
  95. cLetter = in.next().charAt(0);
  96. //finds what day the child is Summoned to school by his/her last name
  97.  
  98. switch(cLetter){
  99. case 'א':
  100. case 'ב':
  101. case 'ג':
  102. case 'ד':
  103. case 'ה':
  104. case 'ו':
  105. case 'ז':
  106. case 'ח':
  107. case 'ט':
  108. case 'י':System.out.println("אתם מוזמנים ליום ראשון");
  109. break;
  110. case 'כ':
  111. case 'ל':
  112. case 'ק':
  113. case 'ר':
  114. case 'ש':
  115. case 'ת':System.out.println("אתם מוזמנים ליום שני");
  116. break;
  117. default:System.out.println("אתם מוזמנים ליום שלישי");
  118. }
  119. }
  120.  
  121. public static void tar4(){
  122.  
  123. int iItem,iItemAmount,iItemPrice;
  124.  
  125. System.out.println("Enter the item number you wish to buy (1-8)");
  126. iItem = in.nextInt();
  127.  
  128. System.out.println("how many would you you like to purchase?");
  129. iItemAmount = in.nextInt();
  130.  
  131. System.out.println("What is the price of a single item?");
  132. iItemPrice = in.nextInt();
  133.  
  134. //finds out if he needs a discount or not then calculates how much discount he deserves
  135. if (iItemAmount > 35)
  136. {
  137. switch (iItem) {
  138. case 1:
  139. case 4:
  140. case 6:System.out.println("You need to pay " + (iItemPrice*0.95)*iItemAmount + " shekels");
  141. break;
  142. case 2:
  143. case 5:System.out.println("You need to pay " + (iItemPrice*0.9)*iItemAmount + " shekels");
  144. break;
  145. case 3:
  146. case 7:
  147. case 8:System.out.println("You need to pay " + (iItemPrice*0.8)*iItemAmount + " shekels");
  148. break;
  149. default:
  150. System.err.println("You were supposed to enter a number from 1-8");
  151. break;
  152. }
  153. }
  154. else if(iItem > 8 || iItem < 1)
  155. {
  156. System.err.println("You were supposed to enter a number from 1-8");
  157. }
  158. else if (iItemAmount <= 35)
  159. {
  160. System.out.println("You need to pay " + (iItemAmount*iItemPrice) + " shekels");
  161. }
  162. }
  163.  
  164. public static void tar5(){
  165.  
  166. int iEmployeeNumber,iSalary;
  167.  
  168. System.out.println("Enter your employee number (1-4)");
  169. iEmployeeNumber = in.nextInt();
  170.  
  171. System.out.println("Enter your salary");
  172. iSalary = in.nextInt();
  173.  
  174.  
  175. //checks what the employee number is and finds out how much taxes the employee needs to pay based on his salary and employee number
  176. switch (iEmployeeNumber) {
  177. case 1:
  178. case 2:
  179. if (iSalary < 3500)
  180. {
  181. System.out.println("You need to pay " + (iSalary * 0.005) + " shekels in taxes");
  182. System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.005) + " shekels");
  183. }
  184. else if (iSalary >= 3500)
  185. {
  186. System.out.println("You need to pay " + (iSalary * 0.0075) + " shekels in taxes");
  187. System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.0075) + " shekels");
  188. }
  189. break;
  190. case 3:
  191. if (iSalary < 5000)
  192. {
  193. System.out.println("You need to pay " + (iSalary * 0.01) + " shekels in taxes");
  194. System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.01) + " shekels");
  195. }
  196. else if (iSalary >= 5000)
  197. {
  198. System.out.println("You need to pay " + (iSalary * 0.025) + " shekels in taxes");
  199. System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.025) + " shekels");
  200. }
  201. break;
  202. case 4:
  203. if (iSalary < 7500)
  204. {
  205. System.out.println("You need to pay " + (iSalary * 0.015) + " shekels in taxes");
  206. System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.015) + " shekels");
  207.  
  208. }
  209. else if (iSalary >= 7500)
  210. {
  211. System.out.println("You need to pay " + (iSalary * 0.02) + " shekels in taxes");
  212. System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.02) + " shekels");
  213.  
  214. }
  215. default:
  216. System.err.println("you were supposed to enter an employee number from 1-4");
  217. break;
  218. }
  219.  
  220. }
  221.  
  222. public static void tar6(){
  223.  
  224. int iDay,iHourIncome,iWorkHours;
  225.  
  226. System.out.println("Enter the number representing the day of the week");
  227. iDay = in.nextInt();
  228.  
  229. System.out.println("Enter your hourly income");
  230. iHourIncome = in.nextInt();
  231.  
  232. System.out.println("Enter how many hours you worked");
  233. iWorkHours = in.nextInt();
  234.  
  235. //finds if employee deserves a discount based on his work hours and prints out his salary to screen
  236. switch (iDay) {
  237. case 1:
  238. case 2:
  239. case 3:
  240. case 4:
  241. case 5:
  242. if (iWorkHours > 8)
  243. {
  244. System.out.println("your salary is " + (8*iHourIncome + (iWorkHours-8)*1.25*iHourIncome) + " shekels");
  245. }
  246. else if (iWorkHours <= 8)
  247. {
  248. System.out.println("your salary is " + (iWorkHours*iHourIncome) + " shekels");
  249. }
  250. break;
  251. case 6:
  252. if (iWorkHours > 5)
  253. {
  254. System.out.println("your salary is " + (5*iHourIncome + (iWorkHours-5)*2.00*iHourIncome) + " shekels");
  255. }
  256. else if (iWorkHours <= 5)
  257. {
  258. System.out.println("your salary is " + (iWorkHours*iHourIncome) + " shekels");
  259. }
  260. break;
  261. case 7:
  262. if (iWorkHours > 5)
  263. {
  264. System.out.println("your salary is " + (5*iHourIncome + (iWorkHours-5)*3*iHourIncome) + " shekels");
  265. }
  266. else if (iWorkHours <= 5)
  267. {
  268. System.out.println("your salary is " + (iWorkHours*iHourIncome) + " shekels");
  269. }
  270. break;
  271. default:
  272. System.err.println("You need enter a number from 1-7");
  273. break;
  274. }
  275. }
  276.  
  277. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement