Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Explain any errors in the following code. If there is any code that is incorrect

ID: 669773 • Letter: E

Question

Explain any errors in the following code. If there is any code that is incorrect, completely correct and rewrite just the line(s) of code that may be incorrect.

import java.util.Scanner;
public class Question {
public static void main ( String args[] ) {
Scanner yellow = new Scanner ( System.in );
System.out.print ( "Enter a number between 8 and 42: " );
int value = yellow.nextInt();
while ( value < 8 && value > 42 ) {
System.out.print ( "Enter a number between 8 and 42: " );
value = yellow.nextInt();
}
System.out.println ( "Thanks for entering " + value + "!" );
}
}

Explanation / Answer

Code is correct.