Advertisement
Guest User

Methods4

a guest
Nov 21st, 2019
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.38 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package javaapplication1;
  7. import javax.swing.JOptionPane;
  8.  
  9.  
  10.  
  11. public class JavaApplication1 {
  12. public static int i = 1;
  13. public static int stockIphone = 10;
  14. public static int stockSamsung = 8;
  15. public static int stockHuawei = 10;
  16. public static int stockOnePlus = 5;
  17.  
  18. public static void main(String[] args) {
  19. for(i = 1; i <= 10; i++){
  20. String[] ticketButtons = {"Iphone 11 - $1500", "Samsung S10 - $800", "Huawei P30 Pro - $850", "One Plus 7 Pro - $650", "Skip"};
  21. int phoneType = JOptionPane.showOptionDialog(null, "Please select the phone you would like to purchase: ", "phone selection",
  22. JOptionPane.WARNING_MESSAGE, 0, null, ticketButtons, ticketButtons[2]);
  23. int warning = warningMessage("");
  24.  
  25.  
  26.  
  27. if(phoneType==0){
  28. if(stockIphone == 10){
  29.  
  30. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  31. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  32. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  33.  
  34. stockIphone -= phoneAmount;
  35. iPhone11(phoneAmount);
  36. }
  37. else if(stockIphone == 9){
  38.  
  39. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
  40. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  41. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  42.  
  43. stockIphone -= phoneAmount;
  44. iPhone11(phoneAmount);
  45. }
  46. else if(stockIphone == 8){
  47.  
  48. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8"};
  49. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  50. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  51.  
  52. stockIphone -= phoneAmount;
  53. iPhone11(phoneAmount);
  54. }
  55. else if(stockIphone == 7){
  56.  
  57. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7"};
  58. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  59. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  60.  
  61. stockIphone -= phoneAmount;
  62. iPhone11(phoneAmount);
  63. }
  64. else if(stockIphone == 6){
  65.  
  66. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6"};
  67. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  68. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  69.  
  70. stockIphone -= phoneAmount;
  71. iPhone11(phoneAmount);
  72. }
  73. else if(stockIphone == 5){
  74.  
  75. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5"};
  76. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  77. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  78.  
  79. stockIphone -= phoneAmount;
  80. iPhone11(phoneAmount);
  81. }
  82. else if(stockIphone == 4){
  83.  
  84. String[] phoneButtons = {"Cancel", "1", "2", "3", "4"};
  85. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  86. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  87.  
  88. stockIphone -= phoneAmount;
  89. iPhone11(phoneAmount);
  90. }
  91. else if(stockIphone == 3){
  92.  
  93. String[] phoneButtons = {"Cancel", "1", "2", "3"};
  94. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  95. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  96.  
  97. stockIphone -= phoneAmount;
  98. iPhone11(phoneAmount);
  99. }
  100. else if(stockIphone == 2){
  101.  
  102. String[] phoneButtons = {"Cancel", "1", "2"};
  103. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  104. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  105.  
  106.  
  107. stockIphone -= phoneAmount;
  108. iPhone11(phoneAmount);
  109. }
  110. else if(stockIphone == 1){
  111.  
  112. String[] phoneButtons = {"Cancel", "1"};
  113. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  114. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  115.  
  116. stockIphone -= phoneAmount;
  117. iPhone11(phoneAmount);
  118. }
  119. else if(stockIphone == 0){
  120. JOptionPane.showMessageDialog(null, "No More Iphone 11's remaining");
  121. }
  122. }
  123.  
  124.  
  125.  
  126. else if(phoneType==1){
  127. if(stockSamsung == 10){
  128.  
  129. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  130. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  131. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  132.  
  133. stockSamsung -= phoneAmount;
  134. SamsungS10(phoneAmount);
  135. }
  136. else if(stockSamsung == 9){
  137.  
  138. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
  139. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  140. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  141.  
  142. stockSamsung -= phoneAmount;
  143. SamsungS10(phoneAmount);
  144. }
  145. else if(stockSamsung == 8){
  146.  
  147. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8"};
  148. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  149. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  150.  
  151. stockSamsung -= phoneAmount;
  152. SamsungS10(phoneAmount);
  153. }
  154. else if(stockSamsung == 7){
  155.  
  156. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7"};
  157. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  158. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  159.  
  160. stockSamsung -= phoneAmount;
  161. SamsungS10(phoneAmount);
  162. }
  163. else if(stockSamsung == 6){
  164.  
  165. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6"};
  166. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  167. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  168.  
  169. stockSamsung -= phoneAmount;
  170. SamsungS10(phoneAmount);
  171. }
  172. else if(stockSamsung == 5){
  173.  
  174. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5"};
  175. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  176. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  177.  
  178. stockSamsung -= phoneAmount;
  179. SamsungS10(phoneAmount);
  180. }
  181. else if(stockSamsung == 4){
  182.  
  183. String[] phoneButtons = {"Cancel", "1", "2", "3", "4"};
  184. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  185. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  186.  
  187. stockSamsung -= phoneAmount;
  188. SamsungS10(phoneAmount);
  189. }
  190. else if(stockSamsung == 3){
  191.  
  192. String[] phoneButtons = {"Cancel", "1", "2", "3"};
  193. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  194. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  195.  
  196. stockSamsung -= phoneAmount;
  197. SamsungS10(phoneAmount);
  198. }
  199. else if(stockSamsung == 2){
  200.  
  201. String[] phoneButtons = {"Cancel", "1", "2"};
  202. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  203. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  204.  
  205. stockSamsung -= phoneAmount;
  206. SamsungS10(phoneAmount);
  207. }
  208. else if(stockSamsung == 1){
  209.  
  210. String[] phoneButtons = {"Cancel", "1"};
  211. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  212. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  213.  
  214. stockSamsung -= phoneAmount;
  215. SamsungS10(phoneAmount);
  216. }
  217. else if(stockSamsung == 0){
  218. JOptionPane.showMessageDialog(null, "No more Samsung S10's Available");
  219. }
  220.  
  221. else if(phoneType==2){
  222.  
  223. if (stockHuawei == 10){
  224. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  225. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  226. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  227.  
  228. stockHuawei -= phoneAmount;
  229. HuaweiP30Pro(phoneAmount);
  230. }
  231.  
  232. if (stockHuawei == 9){
  233. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  234. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  235. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  236.  
  237. stockHuawei -= phoneAmount;
  238. HuaweiP30Pro(phoneAmount);
  239. }
  240.  
  241. if (stockHuawei == 8){
  242. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  243. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  244. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  245.  
  246. stockHuawei -= phoneAmount;
  247. HuaweiP30Pro(phoneAmount);
  248. }
  249.  
  250. if (stockHuawei == 7){
  251. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  252. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  253. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  254.  
  255. stockHuawei -= phoneAmount;
  256. HuaweiP30Pro(phoneAmount);
  257. }
  258.  
  259. if (stockHuawei == 6){
  260. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  261. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  262. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  263.  
  264. stockHuawei -= phoneAmount;
  265. HuaweiP30Pro(phoneAmount);
  266. }
  267.  
  268. if (stockHuawei == 5){
  269. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  270. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  271. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  272.  
  273. stockHuawei -= phoneAmount;
  274. HuaweiP30Pro(phoneAmount);
  275. }
  276.  
  277. if (stockHuawei == 4){
  278. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  279. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  280. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  281.  
  282. stockHuawei -= phoneAmount;
  283. HuaweiP30Pro(phoneAmount);
  284. }
  285.  
  286. if (stockHuawei == 3){
  287. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  288. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  289. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  290.  
  291. stockHuawei -= phoneAmount;
  292. HuaweiP30Pro(phoneAmount);
  293. }
  294.  
  295. if (stockHuawei == 2){
  296. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  297. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  298. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  299.  
  300. stockHuawei -= phoneAmount;
  301. HuaweiP30Pro(phoneAmount);
  302. }
  303.  
  304. if (stockHuawei == 1){
  305. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  306. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  307. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  308.  
  309. stockHuawei -= phoneAmount;
  310. HuaweiP30Pro(phoneAmount);
  311. }
  312.  
  313. else if(stockSamsung == 0){
  314. JOptionPane.showMessageDialog(null, "No more Huawei P30 Pro's Available");
  315. }
  316. }
  317. else if(phoneType==3){
  318. if(stockOnePlus == 10){
  319. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  320. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  321. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  322.  
  323. stockOnePlus -= phoneAmount;
  324. OnePlus7(phoneAmount);
  325. }
  326.  
  327. if(stockOnePlus == 9){
  328. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
  329. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  330. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  331.  
  332. stockOnePlus -= phoneAmount;
  333. OnePlus7(phoneAmount);
  334. }
  335.  
  336. if(stockOnePlus == 8){
  337. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7", "8"};
  338. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  339. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  340.  
  341. stockOnePlus -= phoneAmount;
  342. OnePlus7(phoneAmount);
  343. }
  344.  
  345. if(stockOnePlus == 7){
  346. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6", "7"};
  347. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  348. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  349.  
  350. stockOnePlus -= phoneAmount;
  351. OnePlus7(phoneAmount);
  352. }
  353.  
  354. if(stockOnePlus == 6){
  355. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5", "6"};
  356. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  357. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  358.  
  359. stockOnePlus -= phoneAmount;
  360. OnePlus7(phoneAmount);
  361. }
  362.  
  363. if(stockOnePlus == 5){
  364. String[] phoneButtons = {"Cancel", "1", "2", "3", "4", "5"};
  365. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  366. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  367.  
  368. stockOnePlus -= phoneAmount;
  369. OnePlus7(phoneAmount);
  370. }
  371.  
  372. if(stockOnePlus == 4){
  373. String[] phoneButtons = {"Cancel", "1", "2", "3", "4"};
  374. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  375. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  376.  
  377. stockOnePlus -= phoneAmount;
  378. OnePlus7(phoneAmount);
  379. }
  380.  
  381. if(stockOnePlus == 3){
  382. String[] phoneButtons = {"Cancel", "1", "2", "3"};
  383. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  384. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  385.  
  386. stockOnePlus -= phoneAmount;
  387. OnePlus7(phoneAmount);
  388. }
  389.  
  390. if(stockOnePlus == 2){
  391. String[] phoneButtons = {"Cancel", "1", "2"};
  392. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  393. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  394.  
  395. stockOnePlus -= phoneAmount;
  396. OnePlus7(phoneAmount);
  397. }
  398.  
  399. if(stockOnePlus == 1){
  400. String[] phoneButtons = {"Cancel", "1"};
  401. int phoneAmount = JOptionPane.showOptionDialog(null, "Please select the number of phones you would like to purchase: ", "phone selection",
  402. JOptionPane.WARNING_MESSAGE, 0, null, phoneButtons, phoneButtons[2]);
  403.  
  404. stockOnePlus -= phoneAmount;
  405. OnePlus7(phoneAmount);
  406. }
  407.  
  408. else if(stockSamsung == 0){
  409. JOptionPane.showMessageDialog(null, "No more OnePlus 7's Available");
  410. }
  411.  
  412. }
  413. else if(phoneType==4){
  414. skip(warning);
  415. }
  416. else{
  417. JOptionPane.showMessageDialog(null, "Error, Try again");
  418. i -= 1;
  419. }
  420. }
  421. }
  422. }
  423. public static int getInt(String userMessage) {
  424. int num = Integer.parseInt(JOptionPane.showInputDialog(userMessage));
  425. return num;
  426. }
  427.  
  428. public static double calculate(int quantity, double ticketPrice) {
  429. double amountPayable = quantity * ticketPrice;
  430. return amountPayable;
  431. }
  432. public static void showMessage(double answer) {
  433. JOptionPane.showMessageDialog(null, "Please pay: " +answer);
  434. }
  435. public static int warningMessage(String userMessage){
  436. int skip = JOptionPane.showConfirmDialog(null, "Are you sure you want to be skipped");
  437. if (skip==JOptionPane.YES_OPTION){
  438. JOptionPane.showMessageDialog(null, "Skipped");
  439. }
  440. else if (skip==JOptionPane.NO_OPTION){
  441. i -= 1;
  442. }
  443. return skip;
  444. }
  445. public static void iPhone11(int quantity) {
  446. double price = 1500;
  447. double answer;
  448. answer = calculate(quantity, price);
  449. showMessage(answer);
  450. for(int i = 0; i <= 1; i++){
  451. double money = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter €1500"));
  452. double change = money - 1500;
  453. if (change != money || money < price){
  454. JOptionPane.showMessageDialog(null, "Incorrect amount of change");
  455. i -= 1;
  456. }
  457. else if(money > price){
  458. JOptionPane.showMessageDialog(null, "Order has been placed. change of " + change + "has been returned");
  459. }
  460. else if(money == price){
  461. JOptionPane.showMessageDialog(null, "Order has been placed");
  462. }
  463. }
  464.  
  465.  
  466. System.out.println(stockIphone);
  467. }
  468. public static void SamsungS10(int quantity) {
  469. double price = 800;
  470. double answer;
  471. answer = calculate(quantity, price);
  472. showMessage(answer);
  473. for(int i = 0; i <= 1; i++){
  474. double money = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter €1500"));
  475. double change = money - 1500;
  476. if (change != money || money < price){
  477. JOptionPane.showMessageDialog(null, "Incorrect amount of change");
  478. i -= 1;
  479. }
  480. else if(money > price){
  481. JOptionPane.showMessageDialog(null, "Order has been placed. change of " + change + "has been returned");
  482. }
  483. else if(money == price){
  484. JOptionPane.showMessageDialog(null, "Order has been placed");
  485. }
  486. }
  487. }
  488. public static void HuaweiP30Pro(int quantity) {
  489. double price = 850;
  490. double answer;
  491. answer = calculate(quantity, price);
  492. showMessage(answer);
  493. for(int i = 0; i <= 1; i++){
  494. double money = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter €1500"));
  495. double change = money - 1500;
  496. if (change != money || money < price){
  497. JOptionPane.showMessageDialog(null, "Incorrect amount of change");
  498. i -= 1;
  499. }
  500. else if(money > price){
  501. JOptionPane.showMessageDialog(null, "Order has been placed. change of " + change + "has been returned");
  502. }
  503. else if(money == price){
  504. JOptionPane.showMessageDialog(null, "Order has been placed");
  505. }
  506. }
  507. }
  508. public static void OnePlus7(int quantity) {
  509. double price = 650;
  510. double answer;
  511. answer = calculate(quantity, price);
  512. showMessage(answer);
  513. for(int i = 0; i <= 1; i++){
  514. double money = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter €1500"));
  515. double change = money - 1500;
  516. if (change != money || money < price){
  517. JOptionPane.showMessageDialog(null, "Incorrect amount of change");
  518. i -= 1;
  519. }
  520. else if(money > price){
  521. JOptionPane.showMessageDialog(null, "Order has been placed. change of " + change + "has been returned");
  522. }
  523. else if(money == price){
  524. JOptionPane.showMessageDialog(null, "Order has been placed");
  525. }
  526. }
  527. }
  528.  
  529. public static void skip(int warning){
  530.  
  531. }
  532. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement