Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arrayCart =[];
- totalBill = parseInt(0);
- cartContent = arrayCart.length;
- for(;;)
- {
- userInput = parseInt(prompt('1. Menun2. Your Cartn3. Paymentn4. Exit'))
- switch(userInput)
- {
- // This is to go to Menu
- case 1:
- inputPesanan = prompt('Silahkan pilih menu yang diinginkan:n1. Paket Bento An2. Paket Bento Bn3. Paket Bento C')
- // I think the 1st problem starts here
- switch(inputPesanan)
- {
- case 1:
- arrayCart.push('Paket Bento A - Rp20.000n');
- totalBill += parseInt(20000);
- break;
- case 2:
- arrayCart.push('Paket Bento B - Rp25.000n');
- totalBill += parseInt(25000);
- break;
- case 3:
- arrayCart.push('Paket Bento C - Rp30.000n');
- totalBill += parseInt(30000);
- break;
- }
- break;
- // and the 1st problem ends here
- // This is to check the Cart's content
- case 2:
- // And I think the 2nd problem starts here
- inputKeranjang = alert('Isi Keranjang Andan' + arrayCart + 'nn' + 'Total Tagihan Anda: n' + totalBIll)
- break;
- // and it ends here
- // This is to input how much money you would like to pay with and calculate the change or deficit (if any)
- case 3:
- inputPayment = parseInt(prompt('Total Tagihan Anda :nRp' + totalBill + 'nnBerapa uang yang Anda akan bayarkan?'));
- switch(true)
- {
- case inputPayment<totalBill:
- alert('Uang Anda kurang sebesar Rp ' + parseInt(totalBill-inputPayment));
- break;
- case inputPayment>totalBill:
- alert('Anda akan mendapat kembalian sebesar Rp' + parseInt(inputPayment-totalBill));
- break;
- case inputPayment=totalBill:
- alert('Uang Anda pas');
- break;
- }
- break;
- }
- // This is to end the infinite loop and close the app
- if(userInput === 4)
- {
- break;
- }
- }
Add Comment
Please, Sign In to add comment