Question: Consider the Java code segment below: int value = 1 ; while ( value > 0 ) { System.out.println ( Enter a positive value

Consider the Java code segment below:
int value =1;
while (value >0)
{
System.out.println("Enter a positive value (or <=0 to quit)>");
value = inScan.nextInt();
System.out.println("Your positive value was "+ value);
}
What is wrong with the code segment above? Assume that the rest of the program (including Scanner initialization) is done correctly.
Selected answer will be automatically saved. For keyboard navigation, press up/down arrow keys to select an answer.
a
Nothing is wrong - it will work correctly.
b
It will have an infinite loop
c
It will not print out the final legal value
d
It will print out the sentinel value

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!