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)
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