import java.util.Random;
import java.util.Scanner;
public class CTA {
public static void main(String[] ARGS) {
Random rand = new Random();
Random rand1 = new Random();
Scanner hs = new Scanner();
int n = rand.nextInt();
int o = rand1.nextInt();
if ((n < 1) || (n > 21)) {
System.out.println(rand.nextInt(25));
System.out.println("Value is out of range 1-3");
System.out.println("Please try again");
if (hs == hit) {}
if (hs == stay) {}
}
if ((o < 1) || (o > 21)) {
System.out.println(rand1.nextInt(25));
System.out.println("Value is out of range 1-3");
System.out.println("Please try again");
if (hs == hit) {
System.out.println(rand1.nextInt(25));
}
if (hs == stay) {}
}
}
}
答案 0 :(得分:0)
您将要了解如何使用扫描仪。例如,
if (hs == hit) {
正在测试扫描仪hs是否等于从未声明的变量hit ...您不应该直接测试扫描仪的相等性(这将失败),以及用“命中”替换命中(包括引号)或在上面某处声明String hit = "hit";
。
对于扫描仪,请密切关注此链接中的scanner.next();
。它应该有所帮助:
https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
答案 1 :(得分:0)
如果您只想将两个数字加在一起,那么在您的点击功能中,您将不得不将这两个数字相加,您还需要一个thrid int来获得手数。
int handTotal;
if (hs == hit)
{
handTotal = o + n;
}