Assuming that a user enters 45 as the brightness of a lamp, which of the following hand trace tables is valid for the code below?
Public static void main(String[] args)
{
Int brightness = 0;
Scanner in = new Scanner(System.in) ;
System.out.print(
"Please enter your lamp brightness (in watts) : ") ;
Brightness = in.nextInt() ;
System.out.println("Lamp is " + getDescription(brightness) ) ;
}
Public static String getDescription(int brightness)
{
String description = "";
If (brightness >= 120)
{
Description = "very bright";
If (brightness >= 100)
{
Description = "bright";
}
}
Else
{
Description = "pleasant";
If (brightness <= 50)
{
Description = "dim";
}
}
Return description;
}
A) ![Assuming that a user enters 45 as the brightness of a lamp, which of the following hand trace tables is valid for the code below? Public static void main(String[] args) { Int brightness = 0; Scanner in = new Scanner(System.in) ; System.out.print( Please enter your lamp brightness (in watts) : ) ; Brightness = in.nextInt() ; System.out.println( Lamp is + getDescription(brightness) ) ; } Public static String getDescription(int brightness) { String description = ; If (brightness >= 120) { Description = very bright ; If (brightness >= 100) { Description = bright ; } } Else { Description = pleasant ; If (brightness <= 50) { Description = dim ; } } Return description; } A) B) C) D)](https://d2lvgg3v3hfg70.cloudfront.net/TB4160/11ea8b21_350e_1b5e_ae0b_57d27a4830fe_TB4160_00.jpg)
B) ![Assuming that a user enters 45 as the brightness of a lamp, which of the following hand trace tables is valid for the code below? Public static void main(String[] args) { Int brightness = 0; Scanner in = new Scanner(System.in) ; System.out.print( Please enter your lamp brightness (in watts) : ) ; Brightness = in.nextInt() ; System.out.println( Lamp is + getDescription(brightness) ) ; } Public static String getDescription(int brightness) { String description = ; If (brightness >= 120) { Description = very bright ; If (brightness >= 100) { Description = bright ; } } Else { Description = pleasant ; If (brightness <= 50) { Description = dim ; } } Return description; } A) B) C) D)](https://d2lvgg3v3hfg70.cloudfront.net/TB4160/11ea8b21_350e_426f_ae0b_bf0f82647d14_TB4160_00.jpg)
C) ![Assuming that a user enters 45 as the brightness of a lamp, which of the following hand trace tables is valid for the code below? Public static void main(String[] args) { Int brightness = 0; Scanner in = new Scanner(System.in) ; System.out.print( Please enter your lamp brightness (in watts) : ) ; Brightness = in.nextInt() ; System.out.println( Lamp is + getDescription(brightness) ) ; } Public static String getDescription(int brightness) { String description = ; If (brightness >= 120) { Description = very bright ; If (brightness >= 100) { Description = bright ; } } Else { Description = pleasant ; If (brightness <= 50) { Description = dim ; } } Return description; } A) B) C) D)](https://d2lvgg3v3hfg70.cloudfront.net/TB4160/11ea8b21_350e_4270_ae0b_49b9dfb87564_TB4160_00.jpg)
D) ![Assuming that a user enters 45 as the brightness of a lamp, which of the following hand trace tables is valid for the code below? Public static void main(String[] args) { Int brightness = 0; Scanner in = new Scanner(System.in) ; System.out.print( Please enter your lamp brightness (in watts) : ) ; Brightness = in.nextInt() ; System.out.println( Lamp is + getDescription(brightness) ) ; } Public static String getDescription(int brightness) { String description = ; If (brightness >= 120) { Description = very bright ; If (brightness >= 100) { Description = bright ; } } Else { Description = pleasant ; If (brightness <= 50) { Description = dim ; } } Return description; } A) B) C) D)](https://d2lvgg3v3hfg70.cloudfront.net/TB4160/11ea8b21_350e_6981_ae0b_672429bb4841_TB4160_00.jpg)
Correct Answer:
Verified
Q56: What is wrong with the following code?
Public
Q57: A programmer notices that the following code
Q58: What is the problem with the definition
Q59: You need to write a method that
Q60: Which of the following code snippets can
Q62: For a program that reads city names
Q63: What is a good rule for deciding
Q64: Given the following method, what do we
Q65: Which of the following code snippets can
Q66: What is the purpose of writing a
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents