Java Scanner Class: Integer Input
Thu Oct 05 2023 11:14:51 GMT+0000 (Coordinated Universal Time)
Saved by
@TestProSupport
import java.util.Scanner; // Import the Scanner class
public class Main {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in); // Create a Scanner object
System.out.println("Enter your zip code:");
int zipCode = userInput.nextInt(); // Read user input
System.out.println("Zip code: " + zipCode); // Output user input
}
}
content_copyCOPY
Comments