做一个可乐售卖机的做法
做一个可乐售卖机的做法
准备好所需的材料
这个自动售货机的有点在于电路占地小
一个货币只能对应一个物品 。
投入物品是否正确,都会引发自动售货机吐出商品
锁住电路,阻止自动售货机吐出商品
按照以上步骤即可制作
自动售货机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(c<0||c>6){
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代码,做一个可乐售卖机的做法的全部内容,以及做一个可乐售卖机的做法的相关内容,希望能够帮到您 。
推荐阅读
- 如何确定是不是荨麻疹 如何治疗慢性荨麻疹
- 如何转运气的小方法,如何快速有效的转运改运
- 我国重点治理的三湖,保护滇池的公益用语
- 简述曲柄连杆机构的组成及作用
- 怎样能使皮肤白嫩细腻
- 刺客信条大革命育碧将无条件退款 育碧怎么退款
- 行程卡摘星 上海什么时候解除星号
- 蓝颜和红颜的区别 蓝颜知己是什么关系
- 三星堆国宝文物将再次揭幕 其中,有铜像之王铜像
