import java.util.Scanner; public class Test8 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String username; float price=0.00f; System.out.println("*********************************************"); System.out.println("猜价格"); System.out.println(" 作者:EREC"); System.out.println("*********************************************"); System.out.println("在后台,系统随机产生价格数字,由用户通过平台猜,猜出一个\n" + "数字后,系统机器人通知你信息,大了,小了。再说一个数字,\n" + "直到数字跟系统随机数字一致就游戏结束。"); System.out.println("*********************************************"); System.out.println("请输入用户名字"); username=input.next(); System.out.println(username+",欢迎进入游戏,现在请选择裙子名称,猜价格"); System.out.println("***********************"); System.out.println("1.塞尔维纳(200-300)"); System.out.println("2.颅内漫游指南(500-600)"); System.out.println("***********************"); String num=input.next(); switch(num) { case "1": price=Math.round(Math.random()*100+200);break; case "2": price=Math.round(Math.random()*100+500);break; default: price=Math.round(Math.random()*10000); } System.out.println("请用户猜价格:"); float user_price=input.nextFloat(); boolean flag=false; while(!(user_price==price)) { if(user_price<=0) { flag=true; break; } else if(user_price>price)System.out.println("猜大了"); else System.out.println("猜小了"); user_price=input.nextFloat(); } if(flag)System.out.println("下次继续努力哦"); else System.out.println("猜对啦"); System.out.println("对本系统的使用有什么宝贵意见,可以联系作者或者email"); } }
08猜价格
最新推荐文章于 2024-08-30 22:17:40 发布