自动售货机代码java循环选择 自动售货机代码java循环选择程序( 四 )


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("找你的钱:"+shop.getShopping(i,p));
}
}
}
catch(Exception ex)
{
System.out.println("请正确输入!");
}
}
}
急求简易自动售货机(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");
c=s.nextInt();
}
switch(c){
case 1:
System.out.println("here is your gum");
gum++;
break;
case 2:
System.out.println("here is your chocolate");
cho++;
break;
case 3:
System.out.println("here is your popcorn");
pop++;
break;
case 4:
System.out.println("here is your juice");
jui++;
break;
case 5:
System.out.println(gum+" gum are sold");
System.out.println(cho+" chocolate are sold");
System.out.println(pop+" popcorn are sold");
System.out.println(gum+" juice are sold");
break;
case 6:
System.out.println("system exit");
}
}while(c!=6);
}
public static void play_bord(){
System.out.println("****这是简易售货机,请按下数字选择服务*****");
System.out.println("[1]:get gum");
System.out.println("[2]:get chocolate");
System.out.println("[3]:get popcorn");
System.out.println("[4]:get juice");
System.out.println("[5]:dispaly totalsold");
System.out.println("[6]:quit");
System.out.println("***************************");
}
}
刚好以前写了个 改完给你了
关于自动售货机代码java循环选择和自动售货机代码java循环选择程序的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读