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
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...
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F170cb9b5-2292-4ecc-9f24-3c60291ff66d%2Fffb3e638-8786-42e1-94f6-bce16f69c5ed%2Fugm06bi_processed.jpeg&w=3840&q=75)
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F170cb9b5-2292-4ecc-9f24-3c60291ff66d%2Fffb3e638-8786-42e1-94f6-bce16f69c5ed%2F4j9o5f_processed.jpeg&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
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](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY