<問題>
ランダムにx+y+z, x+y-z, x-y+z, x-y-zを生成し、答えを読み込むことでそれの正誤判定をするプログラムを作成せよ。
<自分が作った回答>
// 暗算力トレーニング
import java.util.Random;
import java.util.Scanner;
class Practice7_10 {
static Scanner stdIn = new Scanner(System.in); //--- 続行の確認 ---// static boolean confirmRetry() { int cont; do { System.out.print("もう一度?<Yes…1/No…0>:"); cont = stdIn.nextInt(); } while (cont != 0 && cont != 1); return cont == 1; } static boolean isMakeQuestion(){ Random rand = new Random(); int x = rand.nextInt(900) + 100; // 3桁の数 int y = rand.nextInt(900) + 100; // 3桁の数 int z = rand.nextInt(900) + 100; // 3桁の数 int[] a = new int[3]; int w = rand.nextInt(3); boolean result; int k0, k1, k2, k3; if(w == 0){ System.out.print(x + " + " + y + " + " + z + " = "); k0 = stdIn.nextInt(); if (result = (k0 == x + y + z)){ return result; } }else if(w == 1){ System.out.print(x + " + " + y + " - " + z + " = "); k1 = stdIn.nextInt(); if (result = (k1 == x + y - z)){ return result; } }else if(w == 2){ System.out.print(x + " - " + y + " + " + z + " = "); k2 = stdIn.nextInt(); if (result = (k2 == x - y + z)){ return result; } }else if(w == 3){ System.out.print(x + " - " + y + " - " + z + " = "); k3 = stdIn.nextInt(); if (result = (k3 == x - y - z)){ return result; } } } public static void main(String[] args) { System.out.println("暗算力トレーニング!!"); do { isMakeQuestion(); } while (confirmRetry()); }
}
<質問>
どうしてもエラーが消えません。頭が混乱してしまっているので状況を紐解いて間違っている部分を解説していただけるとありがたいです。
どこでどういうエラーが出ているのかを書いてください.