Advertisement
rushdie

Presentation 2 Home work

Nov 19th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. package pres_2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class questions {
  6.  
  7. public static void main(String[] args) {
  8. // TODO Auto-generated method stub
  9. Scanner s = new Scanner(System.in);
  10.  
  11.  
  12. /*question 1 teshlom vaad bayt*/
  13.  
  14. int numOfNight;
  15. int doplex;
  16. int rooms;
  17. System.out.println("Enter number of rooms");
  18. rooms = s.nextInt();
  19. System.out.println("Enter number of nights");
  20. numOfNight = s.nextInt();
  21. switch(rooms)
  22. {
  23. case 3:
  24. System.out.println("your cost is "+numOfNight*120);
  25. break;
  26. case 4:
  27. System.out.println("your cost is "+numOfNight*150);
  28. break;
  29. case 5:
  30. System.out.println("doplex:1 \n standart:2");
  31. doplex = s.nextInt();
  32. if(doplex == 1)
  33. {
  34. System.out.println("your cost is "+numOfNight*200);
  35. }
  36. else
  37. {
  38. System.out.println("your cost is "+numOfNight*180);
  39. }
  40. break;
  41. }
  42.  
  43.  
  44.  
  45. /*question 2 sale*/
  46.  
  47. double pay;
  48. int stuffs;
  49. double sum1,sum2;
  50. System.out.println("Enter the sum of your payment");
  51. pay = s.nextDouble();
  52. System.out.println("Enter number of your stuffs");
  53. stuffs = s.nextInt();
  54. if(pay >= 300 && stuffs < 3)
  55. {
  56. sum1 = pay - 50;
  57. System.out.println("price is : "+ sum1);
  58. System.out.println("we use the first sale");
  59. }
  60. if(pay >= 300 && stuffs >= 3 )
  61. {
  62. sum1 = pay - 50;
  63. sum2 = pay * 80 / 100 ;
  64. if(sum1 > sum2)
  65. {
  66. System.out.println("price is : "+ sum2);
  67. System.out.println("we use the secound sale");
  68. }
  69. else
  70. {
  71. System.out.println("price is : "+ sum1);
  72. System.out.println("we use the first sale");
  73. }
  74. }
  75. if(pay < 300 && stuffs >= 3)
  76. {
  77. sum2 = pay * 80 / 100 ;
  78. System.out.println("price is : "+ sum2);
  79. System.out.println("we use the secound sale");
  80. }
  81.  
  82.  
  83.  
  84. /*question 3 grades*/
  85.  
  86. int attendance ;
  87. int middleExamGrade ;
  88. int examGrade ;
  89. int hwGrade;
  90. double temp,finalgrade;
  91.  
  92. System.out.println("Enter your presence");
  93. attendance = s.nextInt();
  94.  
  95. if(attendance >= 80)
  96. {
  97. System.out.println("Enter your exam grade");
  98. examGrade =s.nextInt();
  99. if(examGrade >= 60)
  100. {
  101. System.out.println("Enter your first grade");
  102. middleExamGrade = s.nextInt();
  103. System.out.println("enter your homework grade");
  104. hwGrade = s.nextInt();
  105.  
  106. if(middleExamGrade > examGrade)
  107. {
  108. temp = middleExamGrade * 0.2 + examGrade * 0.8;
  109. }
  110. else
  111. {
  112. temp = examGrade ;
  113. }
  114. finalgrade = 0.1 * hwGrade + 0.9 * temp;
  115. }
  116. else
  117. {
  118. finalgrade = examGrade;
  119. }
  120. }
  121. else
  122. {
  123. finalgrade = 0;
  124. }
  125. System.out.println("Your final grade is : "+finalgrade);
  126.  
  127.  
  128.  
  129.  
  130. /*question 4 Income Tax*/
  131.  
  132. int salary;
  133. char teen;
  134. int children;
  135. char adress;
  136. double tax;
  137.  
  138. System.out.println("Enter your salary");
  139. salary = s.nextInt();
  140. System.out.println("do you teenager ? N/Y");
  141. teen = s.next().charAt(0);
  142. System.out.println("Enter your chlidren number");
  143. children = s.nextInt();
  144. System.out.println("do you live near loglebar ? N/Y");
  145. adress =s.next().charAt(0);
  146.  
  147. if(salary < 5000)
  148. {
  149. tax=0;
  150. }
  151. else if(salary >= 5000 && salary <= 10000)
  152. {
  153. tax = 0.1 * salary;
  154. }
  155. else if(salary >= 10000 && salary <= 15000)
  156. {
  157. tax = 0.35 * salary;
  158. }
  159. else
  160. {
  161. tax = 0.5 * salary;
  162. }
  163. if(teen == 'N' || teen == 'n')
  164. {
  165. if((adress == 'y' || adress == 'Y') && salary > 10000)
  166. {
  167. tax -= 400;
  168. }
  169. if(children > 3)
  170. {
  171. tax -= 900;
  172. }
  173. else
  174. {
  175. tax -= 300 * children;
  176. }
  177. }
  178. else
  179. {
  180. tax = tax * 0.5;
  181. }
  182. System.out.println("you tax is :"+tax);
  183.  
  184.  
  185.  
  186.  
  187. /*question 5 grade of course*/
  188.  
  189. int x;
  190. int n;
  191. double y;
  192. double grade;
  193.  
  194. System.out.println("Enter grade of exam");
  195. x = s.nextInt();
  196. System.out.println("Enter number of your homework");
  197. n = s.nextInt();
  198. System.out.println("Enter the average of homework grade");
  199. y = s.nextDouble();
  200.  
  201. if(n <= 4)
  202. {
  203. System.out.println("your final grade is : "+ x);
  204. }
  205. else if(n >= 5 && n <= 7)
  206. {
  207. if(x >= 60)
  208. {
  209. grade = x*0.8+y*0.2;
  210. System.out.println("your final grade is : "+ grade);
  211. }
  212. else
  213. {
  214. grade = x*0.9+y*0.1;
  215. System.out.println("your final grade is : "+ grade);
  216. }
  217. }
  218. else
  219. {
  220. if(x >= 60)
  221. {
  222. grade = x*0.7+y*0.3;
  223. System.out.println("your final grade is : "+ grade);
  224. }
  225. else
  226. {
  227. grade = x*0.6+y*0.4;
  228. System.out.println("your final grade is : "+ grade);
  229. }
  230. }
  231. }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement