import java.util.Scanner; public class MainClass { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int input = sc.nextInt(); System.out.println("Welcome to the guess game!"); System.out.println("Bob and Angela joined the table"); } }
Dear all,
I'm trying to make a guess game as a total noob where you guess a word between 0 to 10 and two NPC's who will guess to. If you or one NPC got the number right, you or a NPC win. Else, re-run the program. I got an idea of the code in my head but now this problem occurs. You see that i have declared the scanner, and make the program say the intro. Before the welcoming message I declared the integer that you will guess. But the welcoming message and the message that the NPC's have joined only shows when I type a number. Why is this?
Now i'm asking anyway, i have no idea how to re-run the program if no-one got it right. I guess i check if anyone won, and then make an else statement. What do I put in the else statement to re-run the program?
Sorry, English isn't my native language.
Thanks in advance,
Niels.