Hi here is just a fun number guesser where someone inputs a number and my while loop will run until it hits the number inputed. Its just a while loop practice because I am relatively new to Java and wanted more practice. Here is my code. (I am using IntelliJ IDEA)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
boolean password = false;
int passwordGuess = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a Password to be guessed");
int Password = sc.nextInt();
while (password) {
System.out.println("Test");
if (passwordGuess == Password){
System.out.println("Your Password is " + passwordGuess);
password = true;
}
else{
System.out.println(passwordGuess);
passwordGuess++;
}
}
}
}
It prints Enter a Password to be guessed, then I input a number and it prints "Process finished with exit code 0". Any Ideas, Thanks