147k views
2 votes
Write a set of instructions (the code) to prompt the user for an int value and input it using the Scanner class into the variable x and prompt the user for a int value and input it into the variable y.

User Rickson
by
4.7k points

1 Answer

3 votes

import java.util.Scanner;

public class MyClass {

public static void main(String args[]) {

Scanner scan = new Scanner(System.in);

int x = scan.nextInt();

int y = scan.nextInt();

}

}

I hope this helps!

User Richard Barnett
by
4.4k points