📄 xiaofangstore.java
字号:
import java.io.*;
class FoodNamePrice
{
String food;
float price;
public FoodNamePrice(String food,float price)
{
this.food=food;
this.price=price;
}
}
public class XiaoFangStore
{
/*
* 介绍:
*/
public static void Print()
{
System.out.println("Store");
System.out.println("*****************************************************");
System.out.println("\t"+"XiaoFang Convenience Store");
System.out.println("*****************************************************");
System.out.println("<1>Bread"+"\t"+"1.0");
System.out.println("<2>Cocacola"+"\t"+"2.50");
System.out.println("<3>Bear"+"\t"+"\t"+"10.0");
System.out.println("<4>Chocalata"+"\t"+"2.5");
System.out.println("-----------------------------------------------------------");
System.out.print("PLEASE SELECT A NUMBER:");
}
/*
* 根据用户的输入 进行选择输出
*/
public static void userPut() throws java.io.IOException
{
//java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(System.in));
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = reader.readLine();
FoodNamePrice BreadObj=new FoodNamePrice("Bread",1.00f);
FoodNamePrice CocacolaObj=new FoodNamePrice("Cocacola",2.50f);
FoodNamePrice BearObj=new FoodNamePrice("Bear",10.0f);
FoodNamePrice ChocalataObj=new FoodNamePrice("Chocalata",2.50f);
if(Integer.parseInt(input)==1)
{
System.out.println("THANK YOU");
System.out.println("You had selected ["+BreadObj.food+"],"+"$"+BreadObj.price);
System.out.println("--------------");
System.out.println("GOOD BYE");
System.out.println("PLEASE ENTER TO EXIT");
}
if(Integer.parseInt(input)==2)
{
System.out.println("THANK YOU");
System.out.println("You had selected ["+CocacolaObj.food+"],"+"$"+CocacolaObj.price);
System.out.println("--------------");
System.out.println("GOOD BYE");
System.out.println("PLEASE ENTER TO EXIT");
}
if(Integer.parseInt(input)==3)
{
System.out.println("THANK YOU");
System.out.println("You had selected ["+BearObj.food+"],"+"$"+BearObj.price);
System.out.println("--------------");
System.out.println("GOOD BYE");
System.out.println("PLEASE ENTER TO EXIT");
}
if(Integer.parseInt(input)==4)
{
System.out.println("THANK YOU");
System.out.println("You had selected ["+ChocalataObj.food+"],"+"$"+ChocalataObj.price);
System.out.println("--------------");
System.out.println("GOOD BYE");
System.out.println("PLEASE ENTER TO EXIT");
}
if(Integer.parseInt(input)==0)
{
System.out.println("--------------");
System.out.println("GOOD BYE");
System.out.println("[PLEASE ENTER TO EXIT");
}
}
public static void main(String[] args) throws java.io.IOException
{
Print();
userPut();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -