public class menucard
{
public static void main (String [] args)throws IOException
{
Scanner input= new Scanner(System.in);
int tea=5,coffee=7,samosa=8,idly=15,biryani=50,talawa=35,item;
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();
for(int i=1;i<=size;i++)
{
System.out.print("Order Item No"+i+":");
int choice=input.nextInt();
switch(choice)
{
case 1:
System.out.println("TEA : INR "+tea);
break;
case 2:
System.out.println("COFFEE : INR "+coffee);
break;
case 3:
System.out.println("SAMOSA : INR "+samosa);
break;
case 4:
System.out.println("IDLY : INR "+idly);
break;
case 5:
System.out.println("BIRYANI : INR "+biryani);
break;
case 6:
System.out.println("TALAAWA : INR "+talawa);
break;
default:
System.out.println("INVALID ENTRY");
}
}
}
}
输出是:
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:5
Order Item No1:3
SAMOSA : INR 8
Order Item No2:6
TALAAWA : INR 35
Order Item No3:1
TEA : INR 5
Order Item No4:3
SAMOSA : INR 8
Order Item No5:4
IDLY : INR 15
我需要通过添加这些项目的价格来生成账单。
我应该如何添加这些项目..?