JAVA 编程自动售货机系统自助售货机java代码我说,这位同学,你们学校布置的题目你们怎么都来这索取答案来自助售货机java代码了 。怎么不自己动手做做,而且你这里需要一个邮箱接收才行,你这样裸问让人很奇怪 ~
跪谢!求用JAVA编写一个自动贩卖机的程序import java.util.Scanner;
public class Shop
{
private String coffee="咖啡";
private String coke="可乐";
private String tea="茶";
private double coffeeprice=2.00;
private double cokeprice=3.00;
private double teaprice=5;
private double price=0.0;
public Shop()
{
}
public void getName(int i)
{
if(i==1)
{
System.out.println("自助售货机java代码你选择自助售货机java代码的是咖啡");
}
if(i==2)
{
System.out.println("自助售货机java代码你选择的是可乐");
}
if(i==3)
{
System.out.println("自助售货机java代码你选择的是茶");
}
}
public double getShopping(int i,double p)
{
if(i==1)
{
if(pcoffeeprice)
{
System.out.println("您的钱不够买此商品");
}
else
{
price=p-coffeeprice;
}
}
if(i==2)
{
if(pcokeprice)
{
System.out.println("您的钱不够买此商品");
}
else
{
price=p-cokeprice;
}
}
if(i==3)
{
if(pteaprice)
{
System.out.println("您的钱不够买此商品");
}
else
{
price=p-teaprice;
}
}
return price;
}
public static void main(String[] args)
{
Shop shop=new Shop();
try
{
System.out.println("请选择你想要的商品\n 1.咖啡 2.可乐 3.茶");
Scanner si=new Scanner(System.in);
int i=si.nextInt();
System.out.println(" ");
if(i3||i1)
{
System.out.println("没有此产品");
}
else
{
shop.getName(i);
System.out.println(" ");
System.out.print("请付账:");
Scanner sp=new Scanner(System.in);
double p=sp.nextDouble();
System.out.println(" ");
if(shop.getShopping(i,p)!=0.0)
{
System.out.println("找你的钱自助售货机java代码:"+shop.getShopping(i,p));
}
}
}
catch(Exception ex)
{
System.out.println("请正确输入!");
}
}
}
急!java的自动售货机找零程序public class Change {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.print("The goods cost:");
int cost=sc.nextInt();
System.out.print("The customer paid:");
int paid=sc.nextInt();
change(cost,paid);
}
public static void change(int cost,int paid){
//unit of costpaid is dollar
int change=(paid-cost)*100;
int numOfTF=0;//number of 25 cents
int numOfT=0;//number of 10 cents
int numOfF=0;//number of 5 cents
if(change0)//payment is not enough
System.out.println("payment is not enough");
else{
numOfTF=(int)change/25;
numOfT=(int)(change-numOfTF*25)/10;
numOfF=(int)(change-numOfTF*25-numOfT*10)/5;
System.out.println("Change is: "+numOfTF+" 25 cents, "+numOfT+" 10 cents, "+numOfF+" 5 cents.");
}
}
}
急求简易自动售货机(java编程)package com.test;
import java.util.Scanner;
import com.sun.java_cup.internal.internal_error;
public class Demo {
/**
* @param args
*/
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int c;
int gum=0,cho=0,pop=0,jui=0;
do{
Demo.play_bord();
c=s.nextInt();
if(c0||c6){
System.out.println("1-6 only ,input a new choice");
推荐阅读
- java源代码怎么移植到,java源代码怎么移植到数据库
- 怎么查看加显卡的真实型号,怎么看自己的显卡型号
- 疯狂游戏厅单机,疯狂游戏厅单机内购版
- 如何下载煤炉电商,煤炉怎么下单
- c语言自动求和函数 c语言自动求和函数是什么
- oracle查询表的建表语句,oracle怎么看建表语句
- ppt中如何显示图表数据,ppt怎么用图表体现数据
- java清除键盘缓存代码 java清理
- wordpress小工具点,wordpress小程序插件