Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>public static void main(String[] args) { Scanner input = new Scanner(System.in); String s = " MENU \n1.TEA :5\n2.COFFEE :7\n3.SAMOSA :8\n4.IDLY :15\n5.BIRYANI :50\n6.TALAAWA :35\n"; int tea = 5, coffee = 7, samosa = 8, idly = 15, biryani = 50, talawa = 35; System.out .print(" MENU \n1.TEA :5\n2.COFFEE :7\n3.SAMOSA :8\n4.IDLY :15\n5.BIRYANI :50\n6.TALAAWA :35\n \tHow many items you want to order:"); int size = input.nextInt(); ArrayList&lt;String&gt; itemsList = new ArrayList&lt;String&gt;(); ArrayList&lt;Integer&gt; price = new ArrayList&lt;Integer&gt;(); for (int i = 1; i &lt;= size; i++) { System.out.print("Order Item No" + i + ":"); int choice = input.nextInt(); switch (choice) { case 1: System.out.println("TEA : INR " + tea); itemsList.add("Tea"); price.add(tea); System.out.println(s); break; case 2: System.out.println("COFFEE : INR " + coffee); itemsList.add("Coffee"); price.add(coffee); System.out.println(s); break; case 3: System.out.println("SAMOSA : INR " + samosa); itemsList.add("Samosa"); price.add(samosa); System.out.println(s); break; case 4: System.out.println("IDLY : INR " + idly); itemsList.add("Idly"); price.add(idly); System.out.println(s); break; case 5: System.out.println("BIRYANI : INR " + biryani); itemsList.add("Biryani"); price.add(biryani); System.out.println(s); break; case 6: System.out.println("TALAAWA : INR " + talawa); itemsList.add("Talawa"); price.add(talawa); System.out.println(s); break; default: System.out.println("INVALID ENTRY"); } } int total = 0; System.out.println("Item Price"); for (int i = 0; i &lt; itemsList.size(); i++) { System.out.print(itemsList.get(i) + " "); System.out.println(price.get(i)); total = total + price.get(i); } System.out.println("Total " + total); } </code></pre> <p>Output:</p> <pre><code> MENU 1.TEA :5 2.COFFEE :7 3.SAMOSA :8 4.IDLY :15 5.BIRYANI :50 6.TALAAWA :35 How many items you want to order:3 Order Item No1:1 TEA : INR 5 MENU 1.TEA :5 2.COFFEE :7 3.SAMOSA :8 4.IDLY :15 5.BIRYANI :50 6.TALAAWA :35 Order Item No2:2 COFFEE : INR 7 MENU 1.TEA :5 2.COFFEE :7 3.SAMOSA :8 4.IDLY :15 5.BIRYANI :50 6.TALAAWA :35 Order Item No3:3 SAMOSA : INR 8 MENU 1.TEA :5 2.COFFEE :7 3.SAMOSA :8 4.IDLY :15 5.BIRYANI :50 6.TALAAWA :35 Item Price Tea 5 Coffee 7 Samosa 8 Total 20 </code></pre> <p>I edited code to print menu after each case execution and generate the bill in a good way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload