java中pizza,订Pizza(Java)

public classPizza {public static voidmain(String[] args) {//TODO Auto-generated method stub

String Ifm="M";

String ifm="m";

String Ifv="V";

String ifv="v";

String Ifh="H";

String ifh="h";

System.out.println("Welcome to the Java and a Slice Pizza Parlor.");

System.out.print("Please enter a name for our transaction records:");

Scanner a=newScanner(System.in);

String name=a.nextLine();

System.out.println("Thank you,"+name);

System.out.println("Which type of pizza would you like?");

System.out.println("---------------------------------");

System.out.println("[M] Mega-Meaty");

System.out.println("[V] Very Vegetarian");

System.out.println("[H] Heaping Hawaiian");

System.out.println("---------------------------------");

System.out.print("Enter pizza choice:");

Scanner b=newScanner(System.in);

String type=b.nextLine();if(type.equals(ifh)||type.equals(Ifh)||type.equals(ifv)||type.equals(Ifv)||type.equals(ifm)||type.equals(Ifm)) {if(type.equals(ifh)||type.equals(Ifh))

{String newtype="Heaping Hawaiian";

System.out.println("Price list for pizza type:"+newtype);}else if(type.equals(ifm)||type.equals(Ifm))

{String newtype="Mega-Meaty";

System.out.println("Price list for pizza type:"+newtype);}else if(type.equals(ifv)||type.equals(Ifv))

{String newtype="Very Vegetarian";

System.out.println("Price list for pizza type:"+newtype);}

}else{

System.out.println("I'm sorry, BadUser, but that is an invalid choice");

System.out.println("Goodbye.");return;

}

System.out.println("---------------------------------");double prize12=0;double prize16=0;if(type.equals(ifh)||type.equals(Ifh))

{

prize12=10.50;

prize16=14.50;}else if(type.equals(ifv)||type.equals(Ifv))

{

prize12=9.50;

prize16=13.50;

}else{

prize12=11.5;

prize16=15.5;

}

System.out.println("12-inch: $"+prize12);

System.out.println("16-inch: $"+prize16);

System.out.println("---------------------------------");

System.out.println("What size pizza would you like?");

System.out.print("Enter size in inches:");

Scanner c=newScanner(System.in);int size=c.nextInt();if((size!=12&&size!=16))

{

System.out.println("I'm sorry, BadUser, but that is an invalid choice");

System.out.println("Goodbye.");return;

}//ѡ��pizza����

System.out.println("How many pizzas would you like?");

System.out.print("Enter number between 1 and 12:");

Scanner d=newScanner(System.in);int number=d.nextInt();if((number<1)&&number>12)

{

System.out.println("I'm sorry, BadUser, but that is an invalid choice");

System.out.println("Goodbye.");return;

}

System.out.println("Would you like to add Cheezy Bread to that, for a $3.00 charge?");

System.out.print("Please enter Y for yes or N for no:");

Scanner e=newScanner(System.in);

String sure=e.nextLine();//����һ���ַ�

String Ify="Y";

String ify="y";

String Ifn="N";

String ifn="n";if((type.equals(ify)||type.equals(Ify)||type.equals(ifn)||type.equals(Ifn)))

{if(type.equals(ify)||type.equals(Ify))

{;}else{

System.out.println("I'm sorry, BadUser, but that is an invalid choice");

System.out.println("Goodbye.");return;

}

}

System.out.println("---------------------------------");

System.out.println(" Thank you,"+name+". Here is a record of your purchase.");

System.out.println("---------------------------------");

System.out.println(number+" "+size+"-inch Heaping Hawaiian pizzas.");if((type.equals(ify)||type.equals(Ify)))

{

System.out.println("1 order Cheezy Bread.");

}

System.out.println("---------------------------------");double totalprize=0;if(size==12)

{totalprize=prize12*number;}else {totalprize=prize16*number;}if(type.equals(ify)||type.equals(Ify))

{totalprize+=3.00;}

System.out.println("Total cost:"+totalprize);

a.close();

b.close();

c.close();

d.close();

e.close();

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值