Super newbie question here.
I'm taking a course on Udemy and trying to run some of the scripts from the lessons I've taken. As far as I can see, I've entered the script exactly as it's in the lesson video.
Regardless, for some reason, the script just barrels through all of the lines containing Scanner, takes no user input, and somehow runs to the script's end.
I'm using IntelliJ IDEA for all of this. When I run the script, a console window does not even appear for user input.
Below is an example script:
import java.util.Scanner;
public class J4AB_S6_L4 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("The VIP Lounge");
System.out.print("Age:");
int age = scanner.nextInt();
if (age >= 18) {
System.out.println("Do you have a VIP pass? yes/no:");
String vipPassReply = scanner.next();
if (vipPassReply.equals("yes")) {
System.out.println("Thanks, go in.");
}
else {
System.out.println("Sorry you must have a VIP Pass.");
}
}
}
And another script, using Switch.
import java.util.Scanner;
public class J4AB_S6_L7 {
// This is an intro to switch statement syntax.
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
switch (num) {
case 1:
System.out.println("You entered one.");
break;
case 2:
System.out.println("You entered two.");
break;
default:
System.out.println("Dude, why'd you enter that?");
break;
}
}
Why is the script just running through without any user input? Is this a matter of the script itself or IntelliJ IDEA?