帮朋友改的一个订pizza的作业

大概要求就是输入判断,选择pizza的个数和种类,然后返回一个价格

代码放在下面,如果有刚学Java的同学可以参考一下,没有什么难度

public class Pizza {

    public static void main(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=new Scanner(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=new Scanner(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=new Scanner(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=new Scanner(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=new Scanner(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(); } }

订Pizza(Java)的更多相关文章

  1. JAVA上百实例源码以及开源项目

    简介 笔者当初为了学习JAVA,收集了很多经典源码,源码难易程度分为初级.中级.高级等,详情看源码列表,需要的可以直接下载! 这些源码反映了那时那景笔者对未来的盲目,对代码的热情.执着,对IT的憧憬. ...

  2. JAVA上百实例源码网站

    JAVA源码包1JAVA源码包2JAVA源码包3JAVA源码包4 JAVA开源包1 JAVA开源包2 JAVA开源包3 JAVA开源包4 JAVA开源包5 JAVA开源包6 JAVA开源包7 JAVA ...

  3. 487-3279[POJ1002]

    487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 284182   Accepted: 51001 Descr ...

  4. POJ1002 487-3279

    Description 企业喜欢用容易被记住的电话号码.让电话号码容易被记住的一个办法是将它写成一个容易记住的单词或者短语.例如,你需要给滑铁卢大学打电话时,可以拨打TUT-GLOP.有时,只将电话号 ...

  5. 原型模式(Prototype Pattern)

    原型模型:用于创建重复对象,同时保证性能. 这种模式实现一个原型接口,用于创建对象的克隆,当直接创建对象的代价比较大,则可以采用这种模式.例如:一个对象需要高代价的数据库操作之后被创建,这时可以缓存该 ...

  6. pojg487-3279电话号码转换(字符映射)

    http://poj.grids.cn/practice/2974 注意输入中连字符可以任意添加和删除. 描述企业喜欢用容易被记住的电话号码.让电话号码容易被记住的一个办法是将它写成一个容易记住的单词 ...

  7. 设计模式教程(Design Patterns Tutorial)笔记之二 结构型模式(Structural Patterns)

    目录 · Decorator · What is the Decorator Design Pattern? · Sample Code · Adapter · What is the Adapter ...

  8. 水题系列二:PhoneNumbers

    问题描述: Phonenumbers 企业喜欢用容易被记住的电话号码.让电话号码容易被记住的一个办法是将它写成一 个容易记 住的 单词或 者短语 .例如 ,你 需要给 滑铁卢 大学打 电话时 ,可 以 ...

  9. ContentNegotiatingViewResolver多种输出格式实例: json/jsp/xml/xls/pdf

    ContentNegotiatingViewResolver多种输出格式实例: json/jsp/xml/xls/pdf 本例用的是javaConfig配置 以pizza为例. json输出需要用到的 ...

随机推荐

  1. Swagger 生成API文档

    1.打开程序包管理控制台输入: Install-Package Swashbuckle 2.打开App_Start文件夹下的SwaggerConfig.cs文件找到 c.IncludeXmlComme ...

  2. java堆 (转)

     Java栈和堆 ----这两个概念未知很长一段时间,终于找到了一个很好的文本.使用和共享 1. 堆(stack)堆(heap)他们是Java使用Ram本地存储的数据. 与C++不同,Java主动管理 ...

  3. [bug系列]Method not found: 'Void Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory

    bug由来 最近开始学习NetCore,想通过实战使用NetCore做一个集成数据库存储Redis缓存的WebApi项目,由于MSSQL的庞大体积,最终决定使用轻量级关系型数据库MySql. 所以最终 ...

  4. glibc内存管理方式

    程序员接触的内存空间和系统接触的物理内存空间是有所区别的.对于一般进程来讲,他面对的是一个线性虚拟内存空间:地址从0到最大值.每一个进程面对的虚拟内存空间都是一样的,都享有全部的内存地址.虚拟内存空间 ...

  5. [原译]一步步教你制作WPF圆形玻璃按钮

    原文:[原译]一步步教你制作WPF圆形玻璃按钮 图1 1.介绍 从我开始使用vista的时候,我就非常喜欢它的圆形玻璃按钮.WPF最好的一个方面就是允许自定义任何控件的样式.用了一段时间的Micros ...

  6. error C2760: 语法错误: 意外的令牌“标识符”,预期的令牌为“类型说明符”

    解决办法: 打开项目工程----> 属性 ---> c/c++ --> 语音 --> 符合模式 修改成否即可

  7. spring.net的简单使用(一)入门

    Spring.net是一个非常强大的框架和工具,下面是百度百科对它的介绍. Spring.NET为建立企业级应用提供了一套轻量级的解决方案.通过Spring.NET,我们可以用统一且透明的方式来配置应 ...

  8. Delphi7 时钟(使用了多个自定义组件)

    http://download.csdn.net/detail/akof1314/3073289

  9. qt+opencv对两幅图片进行融合

    本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明. 源代码: #include "widget.h" #include "ui ...

  10. 【DRP】-完成物料修改页面Servlet和JSP开发

    本系列博客内容为:做DRP系统中的常用功能. 该项目采用MVC架构 C(Controller)控制器,主要职责;1.取得表单参数:2.调用业务逻辑:3.转向页面 M(Model)模型,主要职责:1.业 ...