Advertisement
Guest User

Untitled

a guest
Nov 20th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. package moviebooking;
  2. import java.util.Scanner;
  3. public class MovieBooking {
  4.  
  5. static Scanner sc = new Scanner(System.in);
  6. static String ID = "moszaza1307";
  7. static String password = "12345";
  8.  
  9. static String ID1;
  10. static String password1;
  11.  
  12. static int movie , time , total , discount1 , menu , total1 , total2;
  13. static double discount , money , change , money1 , discount2;
  14. static String seat[][] ={{"A1","A2","A3","A4","A3","A4","A5","A6"},
  15. {"B1","B2","B3","B4","B3","B4","B5","B6"},
  16. {"C1","C2","C3","C4","C3","C4","C5","C6"},
  17. {"D1","D2","D3","D4","D3","D4","D5","D6"},
  18. {"E1","E2","E3","E4","E3","E4","E5","E6"}};
  19.  
  20. static String select;
  21. public static void login(){
  22. System.out.print("ID: ");
  23. ID1 = sc.next();
  24. System.out.print("Password: ");
  25. password1 = sc.next();
  26. while(!(ID.equals(ID1) && !password.equals(password1))){
  27. System.out.println("login failed, please try again.");
  28. System.out.print("Username: ");
  29. ID = sc.next();
  30. System.out.print("Password: ");
  31. password = sc.next();
  32. }
  33. }
  34. public static void chooseMovie(){
  35. System.out.println("***Movie***");
  36. System.out.println("DOCTOR STRANGE");
  37. System.out.println("FANTASTIC BEASTS");
  38. System.out.println("INFERNO");
  39. System.out.println("YOUR NAME ");
  40. System.out.print("Select>>> ");
  41. movie = sc.nextInt();
  42. switch(movie){
  43. case 1:
  44. System.out.println("***DOCTOR STRANGE***");
  45. System.out.println("1. 09.00\tCinema1");
  46. System.out.println("2. 12.00\tCinema3");
  47. System.out.print("Select>>> ");
  48. time =sc.nextInt();
  49. switch(time){
  50. case 1:
  51. System.out.println("***Cinema1***");
  52. seat();
  53. break;
  54. case 2:
  55. System.out.println("***Cinema3***");
  56. seat();
  57. break;
  58. }
  59. break;
  60. case 2:
  61. System.out.println("***FANTASTIC BEASTS***");
  62. System.out.println("1. 10.00\tCinema2");
  63. System.out.println("2. 14.00\tCinema5");
  64. System.out.print("Select>>> ");
  65. time =sc.nextInt();
  66. switch(time){
  67. case 1:
  68. System.out.println("***Cinema2***");
  69. seat();
  70. break;
  71. case 2:
  72. System.out.println("***Cinema5***");
  73. seat();
  74. break;
  75. }
  76. break;
  77. case 3:
  78. System.out.println("***INFERNO***");
  79. System.out.println("1. 09.30\tCinema5");
  80. System.out.println("2. 14.30\tCinema1");
  81. System.out.print("Select>>> ");
  82. time =sc.nextInt();
  83. switch(time){
  84. case 1:
  85. System.out.println("***Cinema5***");
  86. seat();
  87. break;
  88. case 2:
  89. System.out.println("***Cinema1***");
  90. seat();
  91. break;
  92. }
  93. break;
  94. case 4:
  95. System.out.println("***YOUR NAME***");
  96. System.out.println("1. 17.00\tCinema2");
  97. System.out.println("2. 19.00\tCinema5");
  98. System.out.print("Select>>> ");
  99. time =sc.nextInt();
  100. switch(time){
  101. case 1:
  102. System.out.println("***Cinema2***");
  103. seat();
  104. break;
  105. case 2:
  106. System.out.println("***Cinema5***");
  107. seat();
  108. break;
  109. }
  110. break;
  111. }
  112. }
  113. public static void seat(){
  114. int i=0;
  115. int j=0;
  116. do{ for(i=0; i<seat.length; i++){
  117. for(j=0; j<seat[i].length; j++){
  118. System.out.print(seat[i][j] + " ");
  119. }
  120. System.out.println(" ");
  121. }
  122. System.out.println("OO >>> Exit");
  123. System.out.print("Select>>> ");
  124. select = sc.next();
  125. for(i = 0; i<seat.length;i++){
  126. for(j=0; j<seat[i].length; j++){
  127. System.out.print(seat[i][j] + " ");
  128. }
  129. }
  130. total +=1;
  131. total1 = total-1;
  132. }while(!select.equals("OO") || !select.equals("oo"));
  133. }
  134. public static void discount(){
  135. System.out.println("1. Student Card(5%)");
  136. System.out.println("2. Gift voucher(10%)");
  137. System.out.println("3. Promotion form other(15%)");
  138. System.out.println("4. None");
  139. System.out.print("Select>>> ");
  140. discount1=sc.nextInt();
  141. switch(discount1){
  142. case 1:
  143. discount = (total1*120)*0.95;
  144. System.out.println("Total: "+discount+" B.");
  145. break;
  146. case 2:
  147. discount = (total1*120)*0.9;
  148. System.out.println("Total: "+discount+" B.");
  149. break;
  150. case 3:
  151. discount = (total1*120)*0.85;
  152. System.out.println("Total: "+discount+" B.");
  153. break;
  154. case 4:
  155. discount = total1*120;
  156. System.out.println("Total: "+discount+" B.");
  157. break;
  158. }
  159.  
  160. }
  161. public static void cashier(){
  162. System.out.print("How much money?>>>");
  163. money = sc.nextDouble();
  164. change = money-discount;
  165. System.out.println("Change: "+ change);
  166. }
  167. public static void customerAndmoney(){
  168. total2+=total1;
  169. money1+=discount2;
  170. System.out.println("Customer: "+ total2);
  171. System.out.println("Money: "+ discount2 +"B.");
  172. }
  173. public static void main(String[] args) {
  174. login();
  175. do{System.out.println("***Booking Movie***");
  176. System.out.println(">>120 B./Seat<<");
  177. System.out.println("1. Movie");
  178. System.out.println("2. Cashier");
  179. System.out.println("3. Total customer");
  180. System.out.println("4. Exit");
  181. System.out.print("Select>>> ");
  182. menu = sc.nextInt();
  183. switch(menu){
  184. case 1:
  185. chooseMovie();
  186. break;
  187. case 2:
  188. System.out.println("***Pay for movie***");
  189. discount();
  190. cashier();
  191. discount2+=discount;
  192. break;
  193. case 3:
  194. customerAndmoney();
  195. break;
  196. }
  197. }while(menu!=4);
  198. }
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement