Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.26 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <conio.h>
  4. #define a 1000
  5. #define b 800
  6. #define c 1000
  7. #define d 600
  8. #define e 2000
  9. #define f 3000
  10.  
  11. int main()
  12. {
  13.  
  14. char choice, answer, cont_prog, confirm,n;
  15. float order, price, card, name;
  16.  
  17. do
  18. {
  19.  
  20.  
  21.  
  22.  
  23. printf("Menu\n");
  24. printf("Products available for sale.\n");
  25. printf("1. iPhone 7 $1000\n");
  26. printf("2. iPhone 6 $800\n");
  27. printf("3. iPad Pro $1000\n");
  28. printf("4. Apple Watch $600\n");
  29. printf("5. Macbook Pro $2000\n");
  30. printf("6. iMac $3000\n");
  31. printf("7. Quit\n");
  32. printf("Enter choice: ");
  33. scanf(" %c", &choice);
  34.  
  35. choice = toupper(choice);
  36.  
  37.  
  38. switch( choice )
  39. {
  40. case '1' : printf("How many would you like to buy? \n");
  41. scanf("%f", &order);
  42. printf("Please enter your name\n");
  43. scanf("%f", &name);
  44. printf("Please enter your credit card number\n");
  45. scanf("%f", &card);
  46. if(card < 1000000000000 || card > 10000000000000000)
  47. {
  48. printf("INVALID\n");
  49.  
  50. }
  51. if(card < 100000000000000 && card > 9999999999999)
  52. {
  53. printf("INVALID\n");
  54.  
  55. }
  56. price = order * a;
  57. printf("Name: %c\n",n);
  58. printf("Credit card number: %f\n");
  59. printf("You will have to pay %f\n", price);
  60. printf("Please confirm your order. Y/N\n");
  61. scanf(" %c", &confirm);
  62. confirm = toupper(confirm);
  63. if ( confirm == 'Y')
  64. {
  65. printf("Thank you for purchasing!\n");
  66. }
  67. else if ( confirm == 'N' )
  68. {
  69. printf("Your order has been cancelled.\n");
  70. }
  71. else
  72. {
  73. printf("Invalid input!\n");
  74. }
  75.  
  76. break;
  77.  
  78. case '2' : printf("How many would you like to buy? \n");
  79. scanf("%f", &order);
  80. printf("Please enter your name\n");
  81. scanf("%f", &name);
  82. printf("Please enter your credit card number\n");
  83. scanf("%f", &card);
  84. if(card < 1000000000000 || card > 10000000000000000)
  85. {
  86. printf("INVALID\n");
  87.  
  88. }
  89. if(card < 100000000000000 && card > 9999999999999)
  90. {
  91. printf("INVALID\n");
  92.  
  93. }
  94. price = order * b;
  95. printf("Name: %c\n",n);
  96. printf("Credit card number: %f\n");
  97. printf("You will have to pay %f\n", price);
  98. printf("Please confirm your order. Y/N\n");
  99. scanf(" %c", &confirm);
  100. confirm = toupper(confirm);
  101. if ( confirm == 'Y')
  102. {
  103. printf("Thank you for purchasing!\n");
  104. }
  105. else if ( confirm == 'N' )
  106. {
  107. printf("Your order has been cancelled.\n");
  108. }
  109. else
  110. {
  111. printf("Invalid input!\n");
  112. }
  113.  
  114. break;
  115.  
  116. case '3' : printf("How many would you like to buy? \n");
  117. scanf("%f", &order);
  118. printf("Please enter your name\n");
  119. scanf("%f", &name);
  120. printf("Please enter your credit card number\n");
  121. scanf("%f", &card);
  122. if(card < 1000000000000 || card > 10000000000000000)
  123. {
  124. printf("INVALID\n");
  125.  
  126. }
  127. if(card < 100000000000000 && card > 9999999999999)
  128. {
  129. printf("INVALID\n");
  130.  
  131. }
  132. price = order * c;
  133. printf("Name: %c\n",n);
  134. printf("Credit card number: %f\n");
  135. printf("You will have to pay %f\n", price);
  136. printf("Please confirm your order. Y/N\n");
  137. scanf(" %c", &confirm);
  138. confirm = toupper(confirm);
  139. if ( confirm == 'Y')
  140. {
  141. printf("Thank you for purchasing!\n");
  142. }
  143. else if ( confirm == 'N' )
  144. {
  145. printf("Your order has been cancelled.\n");
  146. }
  147. else
  148. {
  149. printf("Invalid input!\n");
  150. }
  151. break;
  152.  
  153. case '4' : printf("How many would you like to buy? \n");
  154. scanf("%f", &order);
  155. printf("Please enter your name\n");
  156. scanf("%f", &name);
  157. printf("Please enter your credit card number\n");
  158. scanf("%f", &card);
  159. if(card < 1000000000000 || card > 10000000000000000)
  160. {
  161. printf("INVALID\n");
  162.  
  163. }
  164. if(card < 100000000000000 && card > 9999999999999)
  165. {
  166. printf("INVALID\n");
  167.  
  168. }
  169. price = order * d;
  170. printf("Name: %c\n",n);
  171. printf("Credit card number: %f\n");
  172. printf("You will have to pay %f\n", price);
  173. printf("Please confirm your order. Y/N\n");
  174. scanf(" %c", &confirm);
  175. confirm = toupper(confirm);
  176. if ( confirm == 'Y')
  177. {
  178. printf("Thank you for purchasing!\n");
  179. }
  180. else if ( confirm == 'N' )
  181. {
  182. printf("Your order has been cancelled.\n");
  183. }
  184. else
  185. {
  186. printf("Invalid input!\n");
  187. }
  188. break;
  189.  
  190. case '5' : printf("How many would you like to buy? \n");
  191. scanf("%f", &order);
  192. printf("Please enter your name\n");
  193. scanf("%f", &name);
  194. printf("Please enter your credit card number\n");
  195. scanf("%f", &card);
  196. if(card < 1000000000000 || card > 10000000000000000)
  197. {
  198. printf("INVALID\n");
  199.  
  200. }
  201. if(card < 100000000000000 && card > 9999999999999)
  202. {
  203. printf("INVALID\n");
  204.  
  205. }
  206. price = order * e;
  207. printf("Name: %c\n",n);
  208. printf("Credit card number: %f\n");
  209. printf("You will have to pay %f\n", price);
  210. printf("Please confirm your order. Y/N\n");
  211. scanf(" %c", &confirm);
  212. confirm = toupper(confirm);
  213. if ( confirm == 'Y')
  214. {
  215. printf("Thank you for purchasing!\n");
  216. }
  217. else if ( confirm == 'N' )
  218. {
  219. printf("Your order has been cancelled.\n");
  220. }
  221. else
  222. {
  223. printf("Invalid input!\n");
  224. }
  225. break;
  226.  
  227. case '6' : printf("How many would you like to buy? \n");
  228. scanf("%f", &order);
  229. printf("Please enter your name\n");
  230. scanf("%f", &name);
  231. printf("Please enter your credit card number\n");
  232. scanf("%f", &card);
  233. if(card < 1000000000000 || card > 10000000000000000)
  234. {
  235. printf("INVALID\n");
  236.  
  237. }
  238. if(card < 100000000000000 && card > 9999999999999)
  239. {
  240. printf("INVALID\n");
  241.  
  242. }
  243. price = order * f;
  244. printf("Name: %c\n",n);
  245. printf("Credit card number: %f\n");
  246. printf("You will have to pay %f\n", price);
  247. printf("Please confirm your order. Y/N\n");
  248. scanf(" %c", &confirm);
  249. confirm = toupper(confirm);
  250. if ( confirm == 'Y')
  251. {
  252. printf("Thank you for purchasing!\n");
  253. }
  254. else if ( confirm == 'N' )
  255. {
  256. printf("Your order has been cancelled.\n");
  257. }
  258. else
  259. {
  260. printf("Invalid input!\n");
  261. }break;
  262.  
  263.  
  264. case '7' : printf("Bye!\n");
  265. break;
  266.  
  267. default : printf("Invalid input!\n");
  268. }
  269.  
  270. printf("Do you want to start again? (y/n): ");
  271. cont_prog = getchar();
  272. } while (cont_prog == 'y' || cont_prog == 'Y');
  273.  
  274.  
  275. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement