Snippets

Ettar Java - while-Schleife 2

Created by Ettar
public static void main(String[] ARGS){
    Scanner scanner = new Scanner(System.in);
    int gesucht = 3;
    int con=0;

    while(con!=gesucht){
        con=scanner.nextInt();
        if(con>gesucht)
            System.out.println("Zahl zu groß");
        else if(con<gesucht)
            System.out.println("Zahl zu klein");
    }
    System.out.println("Richtig! Die gesuchte Zahl war "+gesucht);

}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.