Advertisement
deathkostis

SKATAMEMELH

Dec 3rd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. char username[50];
  6. char password [50];
  7. char answerSelection;
  8. int seat1;
  9. int seat2;
  10. int seats;
  11.  
  12.  
  13. int costPrint(int cost);
  14. void login ();
  15. void seatSelection();
  16. void printTicket(int cost, char selection[50], int room, int date);
  17.  
  18. int main(int argc, char *argv[]) {
  19.  
  20. char selection[50];
  21. int date;
  22. int room;
  23. int verification;
  24. int cost = 0;
  25.  
  26. seat2 = -1;
  27.  
  28. login();
  29. printf("Please select a movie from the following list: \n \n");
  30. printf("The Avengers \n");
  31. printf("Suicide Squad \n");
  32. printf("Inferno \n");
  33. printf("World War Z \n");
  34.  
  35. do
  36. {
  37. printf("Type your selection: \n");
  38. scanf("%s", selection);
  39. }
  40. while((strcmp(selection, "The") != 0) && (strcmp(selection, "Suicide") != 0) && (strcmp(selection, "Inferno") != 0) && (strcmp(selection, "World") != 0));
  41.  
  42.  
  43. do
  44. {
  45. printf("Please choose the date. Keep in mind that the cinema will be closed after the 24th: \n");
  46. scanf("%d", &date);
  47. }
  48. while((date < 1) || (date > 24));
  49.  
  50. room = 1 + rand() % 20;
  51. printf("Your room is: %d \n", room);
  52.  
  53. do
  54. {
  55. printf("Please type in the number of your room for verification \n");
  56. scanf("%d", &verification);
  57. }
  58. while(verification != room);
  59.  
  60. system("cls");
  61.  
  62. int i;
  63. for(i = 100; i >0; i--)
  64. {
  65. if(i >= 80)
  66. {
  67. if(i == 80)
  68. {
  69. printf("%d \n \n \t", i);
  70. }
  71. else
  72. {
  73. printf("%d ", i);
  74. }
  75. }
  76. else if(i >= 20)
  77. {
  78. if(((i-5)%15 == 0) && (i != 70))
  79. {
  80. printf("%d \n \n \t", i);
  81. }
  82. else
  83. {
  84. if(i == 20)
  85. {
  86. printf("%d \n \n \t \t \t", i);
  87. }
  88. else
  89. {
  90. printf("%d ", i);
  91. }
  92. }
  93. }
  94. else if(i < 20)
  95. {
  96. if(i%10 == 0)
  97. {
  98. printf("%d \n \n \t \t", i);
  99. }
  100. else
  101. {
  102. printf("%d ", i);
  103. }
  104. }
  105.  
  106. }
  107.  
  108. do
  109. {
  110. printf(" \n Please choose the number of seats you want to book: \n");
  111. scanf("%d", &seats);
  112. }
  113. while((seats != 1) && (seats !=2));
  114.  
  115. seatSelection();
  116.  
  117. printf(" \n");
  118.  
  119. for(i = 100; i >0; i--)
  120. {
  121. if(i == seat1)
  122. {
  123. if(seat1 == 80)
  124. {
  125. printf(" 0 \n \n \t");
  126. }
  127. else if(((seat1 < 80) && (seat1 > 20)) && (seat1 != 70) && ((seat1 -5)%15 == 0))
  128. {
  129. printf("0 \n \n \t");
  130. }
  131. else if(seat1 == 20)
  132. {
  133. printf(" 0 \n \n \t \t");
  134. }
  135. else if(seat1 == 10)
  136. {
  137. printf(" 0 \n \n \t \t \t");
  138. }
  139. else
  140. {
  141. printf(" 0 ");
  142. }
  143. }
  144. else if(i == seat2)
  145. {
  146. if(seat2 == 80)
  147. {
  148. printf(" 0 \n \n \t");
  149. }
  150. else if(((seat2 < 80) && (seat2 > 20)) && (seat2 != 70) && ((seat2 -5)%15 == 0))
  151. {
  152. printf("0 \n \n \t");
  153. }
  154. else if(seat2 == 20)
  155. {
  156. printf(" 0 \n \n \t \t");
  157. }
  158. else if(seat2 == 10)
  159. {
  160. printf(" 0 \n \n \t \t \t");
  161. }
  162. else
  163. {
  164. printf(" 0 ");
  165. }
  166. }
  167. else if(i >= 80)
  168. {
  169. if(i == 80)
  170. {
  171. printf("%d \n \n \t", i);
  172. }
  173. else
  174. {
  175. printf("%d ", i);
  176. }
  177. }
  178. else if((i < 80) && (i > 20))
  179. {
  180. if(((i-5)%15 == 0) && (i != 70))
  181. {
  182. printf("%d \n \n \t", i);
  183. }
  184. else
  185. {
  186. printf("%d ", i);
  187. }
  188. }
  189. else if(i == 20)
  190. {
  191. printf("%d \n \n \t \t", i);
  192. }
  193. else if(i < 20)
  194. {
  195. if(i%10 == 0)
  196. {
  197. printf("%d \n \n \t \t \t", i);
  198. }
  199. else
  200. {
  201. printf("%d ", i);
  202. }
  203. }
  204. }
  205.  
  206. cost = costPrint(cost);
  207.  
  208. printTicket(cost, selection, room, date);
  209. return 0;
  210.  
  211. }
  212.  
  213. void login()
  214. {
  215. do
  216. {
  217. printf("Please enter the username \n");
  218. scanf("%s", username);
  219. }
  220. while(strcmp(username, "movie") != 0);
  221.  
  222. do
  223. {
  224. printf("Please enter the password \n");
  225. scanf("%s", password);
  226. }
  227. while(strcmp(password, "mo") != 0);
  228. }
  229.  
  230. void seatSelection()
  231. {
  232. do
  233. {
  234. printf("Please choose the way you want to select your seats \n");
  235. scanf(" %c", &answerSelection);
  236. }
  237. while((answerSelection != 'X') && (answerSelection != 'A'));
  238.  
  239. if(answerSelection == 'X')
  240. {
  241. do
  242. {
  243. printf("Please select your seat: \n");
  244. scanf("%d", &seat1);
  245. }
  246. while((seat1 > 100) && (seat1 < 1));
  247.  
  248. if(seats == 2)
  249. {
  250. do
  251. {
  252. printf("Please select your friend's seat: \n");
  253. scanf("%d", &seat2);
  254. }
  255. while((seat2 > 100) && (seat2 < 1) && (seat2 == seat1) && ((seat2 != seat1 + 1) || (seat2 != seat1 - 1)));
  256. }
  257. }
  258. else
  259. {
  260. seat1 = 1 + rand() % 100;
  261. if(seats == 2)
  262. {
  263. do
  264. {
  265. seat2 = 1 + rand() % 100;
  266. }
  267. while((seat2 > 100) && (seat2 < 1) && (seat2 == seat1) && ((seat2 != seat1 + 1) || (seat2 != seat1 - 1)));
  268. }
  269. }
  270. }
  271.  
  272. int costPrint(int cost)
  273. {
  274. char card[50];
  275.  
  276. if(seats == 1)
  277. {
  278. cost = 10;
  279. }
  280. else
  281. {
  282. cost = 15;
  283. }
  284.  
  285. printf(" \nPlease provide your credit card code: \n");
  286. scanf("%s", card);
  287. return cost;
  288. }
  289.  
  290. void printTicket(int cost, char selection[50], int room, int date)
  291. {
  292. printf("Here is your e-ticket: \n \n");
  293. printf("\t ~~~~~~~~~~~~~~~ Demoup Cinemas ~~~~~~~~~~~~~~~ \n \n");
  294. printf("\t \tTicket No. 1 \n \n ");
  295. if(strcmp(selection, "The") == 0)
  296. {
  297. printf("\t \tMovie: The Avengers \n \n");
  298. }
  299. else if(strcmp(selection, "Suicide \n \n") == 0)
  300. {
  301. printf("\t \tMovie: Suicide Squad \n \n ");
  302. }
  303. else if(strcmp(selection, "World") == 0)
  304. {
  305. printf("\t \tMovie: World War Z \n \n ");
  306. }
  307. else
  308. {
  309. printf("\t \tMovie: Inferno \n \n");
  310. }
  311. printf("\t \tDate: %d/12/2016 \t \tRoom: %d \t \tSeat: %d \n \n \n", date, room, seat1);
  312. printf("\t \t \t Total Cost: %d euro \n \n", cost);
  313. printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  314.  
  315. if(seats == 2)
  316. {
  317. printf("\nHere is your e-ticket: \n \n");
  318. printf("\t ~~~~~~~~~~~~~~~ Demoup Cinemas ~~~~~~~~~~~~~~~ \n \n");
  319. printf("\t \tTicket No. 2 \n \n ");
  320. if(strcmp(selection, "The") == 0)
  321. {
  322. printf("\t \tMovie: The Avengers \n \n");
  323. }
  324. else if(strcmp(selection, "Suicide \n \n") == 0)
  325. {
  326. printf("\t \tMovie: Suicide Squad \n \n ");
  327. }
  328. else if(strcmp(selection, "World") == 0)
  329. {
  330. printf("\t \tMovie: World War Z \n \n ");
  331. }
  332. else
  333. {
  334. printf("\t \tMovie: Inferno \n \n");
  335. }
  336. printf("\t \tDate: %d/12/2016 \t \tRoom: %d \t \tSeat: %d \n \n \n", date, room, seat2);
  337. printf("\t \t \t Total Cost: %d euro \n \n", cost);
  338. printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  339. }
  340.  
  341. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement