红石自动售货机制作教程: 需要材料:红石火把、红石、投掷器、方块、漏斗、比较器、红石灯、箱子 两个漏斗方向朝箱子,下面的漏斗接上箱子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("***************************"); }}刚好以前写了个 改完给你了