幸运猜猜猜游戏java_幸运猜数游戏

幸运猜数游戏

[free]          此游戏为猜1-100之内的随机数错了会给你提示。猜对了会给你鼓励,看你能最少用多少时间猜出来,但是小心会给你教训哦。

源代码为本人原创:希望个各位有兴趣的朋友来一起来学习与赐教 更希望提出一些宝贵的意见 ,来共同进步。

[/free]

21c92f7342edc52acb5684b0b88bdcec.png程序代码:[free][free][free]import java.util.Scanner;

public class Cai{

public static void main(String[] args){

Scanner input=new Scanner(System.in);

int count;

int shu;

String ok="y";

do{

System.out.println("我心里有一个0到99之间的整数,你猜是什么?");

int number=(int)(Math.random()*100);

for(count=1;count<=20;count++){

shu=input.nextInt();

if(shu

System.out.println("小了点,再试试!");

continue;

}else if(shu>number){

System.out.println("大了点,再试试!");

continue;

}else if(shu==number&&count==1){

System.out.println("你太有才了");

break;

}else if(shu==number&&count>=2&&count<=6){

System.out.println("这么快就猜出来了,很聪明么!");

break;

}else if(shu==number&&count>7){

System.out.println("猜了半天才猜出来,小同志,尚需努力啊!");

break;

}else if(count==20){

System.out.println("对不起!您已没有机会进行猜数游戏。");

}else {

System.out.println("对不起!您的输入有错请重新输入。");

}

}

System.out.println("您还想进行游戏吗?y/n");

ok=input.next();

if(ok.equals("n")){

break;

}else if(ok.equals("y")){

continue;

}else{

System.out.println("您的输入有误,请继续输入!");

ok=input.next();

}

}while(ok.equals("y"));

System.out.println("程序结束!");

}

}import java.util.Scanner;

public class Cai{

public static void main(String[] args){

Scanner input=new Scanner(System.in);

int count;

int shu;

String ok="y";

do{

System.out.println("我心里有一个0到99之间的整数,你猜是什么?");

int number=(int)(Math.random()*100);

for(count=1;count<=20;count++){

shu=input.nextInt();

if(shu

System.out.println("小了点,再试试!");

continue;

}else if(shu>number){

System.out.println("大了点,再试试!");

continue;

}else if(shu==number&&count==1){

System.out.println("你太有才了");

break;

}else if(shu==number&&count>=2&&count<=6){

System.out.println("这么快就猜出来了,很聪明么!");

break;

}else if(shu==number&&count>7){

System.out.println("猜了半天才猜出来,小同志,尚需努力啊!");

break;

}else if(count==20){

System.out.println("对不起!您已没有机会进行猜数游戏。");

}else {

System.out.println("对不起!您的输入有错请重新输入。");

}

}

System.out.println("您还想进行游戏吗?y/n");

ok=input.next();

if(ok.equals("n")){

break;

}else if(ok.equals("y")){

continue;

}else{

System.out.println("您的输入有误,请继续输入!");

ok=input.next();

}

}while(ok.equals("y"));

System.out.println("程序结束!");

}

}[/free][/free][/free]

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值