Guest User

Untitled

a guest
Jul 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. arrayCart =[];
  2. totalBill = parseInt(0);
  3. cartContent = arrayCart.length;
  4.  
  5. for(;;)
  6. {
  7. userInput = parseInt(prompt('1. Menun2. Your Cartn3. Paymentn4. Exit'))
  8. switch(userInput)
  9. {
  10. // This is to go to Menu
  11. case 1:
  12. inputPesanan = prompt('Silahkan pilih menu yang diinginkan:n1. Paket Bento An2. Paket Bento Bn3. Paket Bento C')
  13.  
  14.  
  15. // I think the 1st problem starts here
  16. switch(inputPesanan)
  17. {
  18. case 1:
  19. arrayCart.push('Paket Bento A - Rp20.000n');
  20. totalBill += parseInt(20000);
  21. break;
  22.  
  23. case 2:
  24. arrayCart.push('Paket Bento B - Rp25.000n');
  25. totalBill += parseInt(25000);
  26. break;
  27.  
  28. case 3:
  29. arrayCart.push('Paket Bento C - Rp30.000n');
  30. totalBill += parseInt(30000);
  31. break;
  32. }
  33. break;
  34. // and the 1st problem ends here
  35.  
  36. // This is to check the Cart's content
  37. case 2:
  38. // And I think the 2nd problem starts here
  39. inputKeranjang = alert('Isi Keranjang Andan' + arrayCart + 'nn' + 'Total Tagihan Anda: n' + totalBIll)
  40. break;
  41. // and it ends here
  42.  
  43. // This is to input how much money you would like to pay with and calculate the change or deficit (if any)
  44. case 3:
  45. inputPayment = parseInt(prompt('Total Tagihan Anda :nRp' + totalBill + 'nnBerapa uang yang Anda akan bayarkan?'));
  46. switch(true)
  47. {
  48. case inputPayment<totalBill:
  49. alert('Uang Anda kurang sebesar Rp ' + parseInt(totalBill-inputPayment));
  50. break;
  51.  
  52. case inputPayment>totalBill:
  53. alert('Anda akan mendapat kembalian sebesar Rp' + parseInt(inputPayment-totalBill));
  54. break;
  55.  
  56. case inputPayment=totalBill:
  57. alert('Uang Anda pas');
  58. break;
  59. }
  60. break;
  61. }
  62.  
  63. // This is to end the infinite loop and close the app
  64. if(userInput === 4)
  65. {
  66. break;
  67. }
  68. }
Add Comment
Please, Sign In to add comment