标签:ext 输入 ber double 实验 输入数据 and next []
package 实验二;
import java.util.Scanner;
public class suijishu{
public static void main(String[] args) {
// TODO Auto-generated method stub
gameing();
}
public static double suijishu()
{
double number=Math.random()*2+988;
return number;
}
public static double bijiao(double m,double n)
{
if(n>m)
{
return 1;
}
else if(n==m)
{
return 0;
}
else
{
return -1;
}
}
public static void gameing()
{
int k=0;
double i=suijishu();
for(int j=1;j<=10;j++)
{
System.out.println("请输入数据");
Scanner sc=new Scanner(System.in);
int y=sc.nextInt();
System.out.println(+y);
double h=bijiao(i,y);
if(h>0)
{
System.out.println("猜的数大");
System.out.println("是否要继续");
System.out.println("退出按0,继续按任意键");
Scanner sc1=new Scanner(System.in);
int y1=sc1.nextInt();
if(y1==0)
{System.exit(1);}
k++;
if(k==10)
{
System.out.println("您输入的次数用完");
System.exit(1);
}
continue;
}
else if(h==0)
{
System.out.println("输入正确");
break;
}
else
{
System.out.println("猜的数小");
System.out.println("是否要继续");
System.out.println("退出按0,继续按任意键");
Scanner sc2=new Scanner(System.in);
int y2=sc2.nextInt();
if(y2==0)
{
System.exit(1);
}
k++;
if(k==10)
{
System.out.println("您输入的次数用完");
System.exit(1);
}
continue;
}
}
}
}
标签:ext 输入 ber double 实验 输入数据 and next []
原文地址:http://www.cnblogs.com/jiazehao/p/7592666.html