229k views
4 votes
Write a statement that outputs variable userNum. End with a newline.

1 Answer

3 votes

Answer:

System.out.println(userNum);

Step-by-step explanation:

Using Java programming language, lets assume the variable userNum is entered by a user. The code snippet below will prompt the user to enter a number and output the the variable:

import java.util.Scanner;

public class TestClass {

public static void main(String[] args) {

System.out.println("Enter a number");

Scanner input = new Scanner(System.in);

int userNum = input.nextInt();

System.out.println(userNum);

}

}

User Dyno Cris
by
3.7k points