-2
我正在執行計算機猜測您的號碼的程序。並且它必須猜測一個隨機數。但是我怎麼讓隨機線低於或者高於num的數量呢?生成小於或大於「x」的隨機數字
package compguse;
import java.util.*;
public class Compguse {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
String a;
String b;
String c;
String ans;
String d;
int input =1;
System.out.println("do u have your number?");
a = scan.nextLine();
while (a.equalsIgnoreCase("yes"))
{
int ran = (int) Math.floor(Math.random()*100)+1;
System.out.println(" is" +ran +" your num?");
a = scan.nextLine();
if(a.equalsIgnoreCase("no"))
{
System.out.println("Was i too high or low?");
b = scan.nextLine();
if(b.equalsIgnoreCase("high"))
{
int ran1 = (int) Math.floor(Math.random() < (int) ran);
}
}
}
}
如何把它放在代碼形式? – idk0namz