Question: What is the function of the following code? Scanner scan = new Scanner ( System . in ) ; System.out.print ( Enter an integer:

What is the function of the following code?
Scanner scan = new Scanner(System.in);
System.out.print("Enter an integer: ");
number = scan.nextInt();
while (number <=0)
{
System.out.print("That number was not correct.");
System.out.print("Enter another integer: ");
number = scan.nextInt();
}
a.
Makes sure the input is negative
b.
Makes sure the input is positive
c.
Makes sure the users inputs a number
d.
Makes sure the user inputs a number without error

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!