Solved

Assuming That a User Enters 45 as the Brightness of a Lamp

Question 61

Multiple Choice

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

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents