41 color2 = color2.toLowerCase(); 42 43 44 // Step 6: Display a message according to the following: second color red 45 46 // first color light blue . red otherwise message That's wonderful! That's even better! 47 // // // if(color1.equals("lightblue") && color2.equals("red")){ System.out.println("That's wonderful!"); 48 light blue 49 That's also great! 50 51 52 else if(color1.equals("red") && color2.equals("lightblue")){ System.out.println("That's even better!"); 53 54 55 else{ System.out.println("That's also grèat!"); } 56 57 58 59 60 61 62 CodeCheck Reset Download Testing TwoColors.java Test 1 Input: red LIGHT BLUE Expected Actual Enter your first favorite color: Enter your second favorite color: Enter your first favorite color: Enter your second favorite color: That's even better! That's also great! fail Test 2 MacBook Air

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Fix the code, make it look like the expect
public class TwoColors
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
10
11
12
13
14
15
16
System.out.print("Enter your first favorite color: ");
17
// Step 2: Read in the next line of input and assign
it to a String variable colorl
18
19
//
20
String colorl = in.nextLine();
21
22
23
24
// Step 3: Trim spaces from both end and convert the
input to all lowercase and assign it back
to the same variable
25
26
//
27
//
28
29
colorl = colorl.toLowerCase);
System.out.println("Enter your second favorite color: ");
31
32
// Step 4: Read in the next line of input and assign
it to a String variable color2
33
//
34
35
String color2 = in.nextLine();
36
37
// Step 5: Trim spaces from both end and convert the
38
//
//
input to all lowercase and assign it back
to the same variable
39
40
41
color2 = color2.toLowerCase();
42
43
44
45
// Step 6: Display a message according to the following:
//
46
first color
second color
message
That's wonderful!
That's even better!
47
//
//
//
light blue
red
48
red
light blue
49
otherwise
That's also great!
if(color1.equals("lightblue") && color2.equals("red")){
50
MacB
esc
80
00
F1
F2
F3
F4
F5
Transcribed Image Text:public class TwoColors { public static void main(String[] args) { Scanner in = new Scanner(System.in); 10 11 12 13 14 15 16 System.out.print("Enter your first favorite color: "); 17 // Step 2: Read in the next line of input and assign it to a String variable colorl 18 19 // 20 String colorl = in.nextLine(); 21 22 23 24 // Step 3: Trim spaces from both end and convert the input to all lowercase and assign it back to the same variable 25 26 // 27 // 28 29 colorl = colorl.toLowerCase); System.out.println("Enter your second favorite color: "); 31 32 // Step 4: Read in the next line of input and assign it to a String variable color2 33 // 34 35 String color2 = in.nextLine(); 36 37 // Step 5: Trim spaces from both end and convert the 38 // // input to all lowercase and assign it back to the same variable 39 40 41 color2 = color2.toLowerCase(); 42 43 44 45 // Step 6: Display a message according to the following: // 46 first color second color message That's wonderful! That's even better! 47 // // // light blue red 48 red light blue 49 otherwise That's also great! if(color1.equals("lightblue") && color2.equals("red")){ 50 MacB esc 80 00 F1 F2 F3 F4 F5
41
color2 = color2.toLowerCase();
42
43
44
// Step 6: Display a message according to the following:
//
45
46
first color
second color
message
That's wonderful!
That's even better!
That's also great!
47
light blue
. red
otherwise
//
red
48
light blue
//
//
49
50
if(color1.equals("lightblue") && color2.equals("red")){
51
System.out.println("That's wonderful!");
52
else if(colorl.equals("red") & color2.equals("lightblue")){
System.out.println("That's even better!");
53
54
55
56
else{
System.out.println("That's also great!");
}
57
58
59
60
}
61 }
62
CodeCheck
Reset
Download
Testing TwoColors.java
Test 1
Input:
red
LIGHT BLUE
Expected
Actual
Enter your first favorite color: Enter your second favorite color: Enter your first favorite color: Enter your second favorite color: That's even better!
That's also great!
fail
Test 2
MacBook Air
DII
F9
FB
Transcribed Image Text:41 color2 = color2.toLowerCase(); 42 43 44 // Step 6: Display a message according to the following: // 45 46 first color second color message That's wonderful! That's even better! That's also great! 47 light blue . red otherwise // red 48 light blue // // 49 50 if(color1.equals("lightblue") && color2.equals("red")){ 51 System.out.println("That's wonderful!"); 52 else if(colorl.equals("red") & color2.equals("lightblue")){ System.out.println("That's even better!"); 53 54 55 56 else{ System.out.println("That's also great!"); } 57 58 59 60 } 61 } 62 CodeCheck Reset Download Testing TwoColors.java Test 1 Input: red LIGHT BLUE Expected Actual Enter your first favorite color: Enter your second favorite color: Enter your first favorite color: Enter your second favorite color: That's even better! That's also great! fail Test 2 MacBook Air DII F9 FB
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY