Biology Forums - Study Force

Science-Related Homework Help Computer Studies Topic started by: spruckj on May 5, 2020



Title: Analyze the following code: // Enter an integer Scanner input = new Scanner(System.in); int number = ...
Post by: spruckj on May 5, 2020
Analyze the following code:

// Enter an integer
Scanner input = new Scanner(System.in);
int number = input.nextInt();

if (number <= 0)
System.out.println(number);


▸ If number is positive, number is displayed.

▸ System.out.println(number); must be placed inside braces.

▸ number entered from the input cannot be negative.

▸ The if statement is wrong, because it does not have the else clause.

▸ If number is zero, number is displayed.


Title: Analyze the following code: // Enter an integer Scanner input = new Scanner(System.in); int number = ...
Post by: BobbyD on May 5, 2020
Content hidden