mardi 12 novembre 2019

else without if and I don't get why (short code) [on hold]

I get two errors saying there is else without if in the while loop after an if statement. I been starring at the screen for like an hour now and I don't get the problem.

May you help me :-) <3

import java.util.Random;
import java.util.Scanner;

public class GuessingGame {

    public static void main(String[] args) {

        Random rand = new Random();
        int zahl = rand.nextInt(1000)+1;
        Scanner Eingabe = new Scanner(System.in);
        int guess;
        boolean win = false;

        System.out.println("Welcome!");

        while (win == false){

            System.out.println("Please enter your guess: ");
        guess = Eingabe.nextInt();

        if (guess == zahl);
        {
            win = true;


        }
        else if (guess < zahl);{
            System.out.println("Too small!");
        }
        else if (guess > zahl) {
            System.out.println("Too big!");
        }

    }
        System.out.println("You win!");
}}
´´´

Aucun commentaire:

Enregistrer un commentaire