Please help me fix the code Make it like the first picture(expect). And show the step 16-19 Thank you
Please help me fix the code Make it like the first picture(expect). And show the step 16-19 Thank you
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
Please help me fix the code
Make it like the first picture(expect).
And show the step 16-19
Thank you
![1 public class StringTester
2 {
3
public static void main(String(] args)
山凸
// Step 2: Declare three String variables strl, str2, and str
String namel = "strl";
String name2 = "str2";
String name3 = "str3";
6.
A codecheck.it/files/21021001249p1b4a9sn32n
// Step 3: Create a new String object with "Java" and
assign it to strl
String strl = new string("Java");
10
Actual
Expected
11
//
X 12
13
Java
Java
// Step 4: Create a new String object with "CS 46A" and
14
Expected: Java
CS 46A
Expected: CS 46A Expected: CS 46A
Expected:TJava
CS 46A
15
//
assign it to str2
String str2 = new string("CS 46A");
X 16
17
// Step 5: Display stri on a line
System.out.println(strl);
4
18
Expected: 4
19
Expected: 4
6.
Expected: 6
JAVA
20
Expected: 6
Java
21
System.out.println("Expected: Java");
22
Check letter case
Expected: JAVA
CS 46A
Check letter case
Expected: cs 46a
CS 46A
Expected: SE 46A
CS 46A
Expected: CS46A
Java
// Step 6: Display str2 on a line
System.out.println(str2);
23
Expected: JAVA
cs 46a
System.out.println("Expected: CS 46A");
Expected: cs 46a
SE 46A
// Step 7: Get the number of characters of stri and
//
int numofChars = strl.lenght();
assign it to an integer variable numofChars
Expected: SE 46A
CS46A
Expected: CS46A
Java
Expected: Java
CS 46A
Expected: CS 46A Expected: CS 46A
// Step 8: Display numofChars on a line
System.out.println(numofChars);
Expected: Java
CS 46A
System.out.println("Expected: 4");
36
//Step 9: Display the number of characters of str2 on a line
System.out.println(str2.length());
37
40
System.out.println("Expected: 6");
41
42
// Step 10: Call method toUpperCase() on strl and assign the](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F170cb9b5-2292-4ecc-9f24-3c60291ff66d%2F17e7bc21-104e-4cf3-9715-f4ce536b16a7%2F7mv88xb_processed.jpeg&w=3840&q=75)
Transcribed Image Text:1 public class StringTester
2 {
3
public static void main(String(] args)
山凸
// Step 2: Declare three String variables strl, str2, and str
String namel = "strl";
String name2 = "str2";
String name3 = "str3";
6.
A codecheck.it/files/21021001249p1b4a9sn32n
// Step 3: Create a new String object with "Java" and
assign it to strl
String strl = new string("Java");
10
Actual
Expected
11
//
X 12
13
Java
Java
// Step 4: Create a new String object with "CS 46A" and
14
Expected: Java
CS 46A
Expected: CS 46A Expected: CS 46A
Expected:TJava
CS 46A
15
//
assign it to str2
String str2 = new string("CS 46A");
X 16
17
// Step 5: Display stri on a line
System.out.println(strl);
4
18
Expected: 4
19
Expected: 4
6.
Expected: 6
JAVA
20
Expected: 6
Java
21
System.out.println("Expected: Java");
22
Check letter case
Expected: JAVA
CS 46A
Check letter case
Expected: cs 46a
CS 46A
Expected: SE 46A
CS 46A
Expected: CS46A
Java
// Step 6: Display str2 on a line
System.out.println(str2);
23
Expected: JAVA
cs 46a
System.out.println("Expected: CS 46A");
Expected: cs 46a
SE 46A
// Step 7: Get the number of characters of stri and
//
int numofChars = strl.lenght();
assign it to an integer variable numofChars
Expected: SE 46A
CS46A
Expected: CS46A
Java
Expected: Java
CS 46A
Expected: CS 46A Expected: CS 46A
// Step 8: Display numofChars on a line
System.out.println(numofChars);
Expected: Java
CS 46A
System.out.println("Expected: 4");
36
//Step 9: Display the number of characters of str2 on a line
System.out.println(str2.length());
37
40
System.out.println("Expected: 6");
41
42
// Step 10: Call method toUpperCase() on strl and assign the
![36
return value to str
str = str2.toLowerCase();
37
// Step 9: Display the number of characters of str2 on a line
System.out.println(str2.length());
%3D
38
39
5
6
// Step 13: Display str on a line
System.out.println(str2);
40
System.out.println("Expected: 6");
41
42
// Step 10: Call method toUpperCase() on strl and assign the
18
System.out.println("Expected: cs 46a");
43
//
return value to str
59
44
String str = strl.toUpperCase();
// Step 14: Call method replace() on str2 to replace "CS" with
"SE" and assign the return value to str
50
45
61
62
//
46
// Step 11: Display str on a line
System.out.println(str1);
str = str2.replace("CS" , "SE");
47
63
48
64
49
System.out.println("Expected: JAVA");
65
// Step 15: Display str on a line
50
66
51
// Step 12: Call method tolowerCase() on str2 and assign the
67
System.out.println(str);
System.out.println("Expected: SE 46A");
52
//
str = str2.toLowerCase();
return value to str
68
53
69
54
// Step 16: Call method replace() on str2 to replace " " with
//
70
// Step 13: Display str on a line
System.out.println(str2);
55
56
71
"" and assign the return value to str
57
72
58
System.out.println("Expected: cs 46a");
73
59
74
// Step 17: Display str on a line
// Step 14: Call method replace() on str2 to replace "CS" with
//
str = str2.replace("CS", "SE");
75
60
61
"SE" and assign the return value to str
76
62
77
System.out.println("Expected: CS46A");
63
78
64
79
// Step 18: Display strl on a line
65
// Step 15: Display str on a line
80
66
81
System.out.println(str);
System.out.println("Expected: SE 46A");
67
82
System.out.println("Expected: Java");
68
83
69
84
// Step 19: Display str2 on a line
// Step 16: Call method replace() on str2 to replace" with
//
70
85
71
*" and assign the return value to str
86
72
87
System.out.println("Expected: CS 46A");
73
88
74
// Step 17: Display str on a line
89 )
75
90
76
77
System.out.printin("Expected: C546A");-
78
MacBook Air](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F170cb9b5-2292-4ecc-9f24-3c60291ff66d%2F17e7bc21-104e-4cf3-9715-f4ce536b16a7%2F6jbx42e_processed.jpeg&w=3840&q=75)
Transcribed Image Text:36
return value to str
str = str2.toLowerCase();
37
// Step 9: Display the number of characters of str2 on a line
System.out.println(str2.length());
%3D
38
39
5
6
// Step 13: Display str on a line
System.out.println(str2);
40
System.out.println("Expected: 6");
41
42
// Step 10: Call method toUpperCase() on strl and assign the
18
System.out.println("Expected: cs 46a");
43
//
return value to str
59
44
String str = strl.toUpperCase();
// Step 14: Call method replace() on str2 to replace "CS" with
"SE" and assign the return value to str
50
45
61
62
//
46
// Step 11: Display str on a line
System.out.println(str1);
str = str2.replace("CS" , "SE");
47
63
48
64
49
System.out.println("Expected: JAVA");
65
// Step 15: Display str on a line
50
66
51
// Step 12: Call method tolowerCase() on str2 and assign the
67
System.out.println(str);
System.out.println("Expected: SE 46A");
52
//
str = str2.toLowerCase();
return value to str
68
53
69
54
// Step 16: Call method replace() on str2 to replace " " with
//
70
// Step 13: Display str on a line
System.out.println(str2);
55
56
71
"" and assign the return value to str
57
72
58
System.out.println("Expected: cs 46a");
73
59
74
// Step 17: Display str on a line
// Step 14: Call method replace() on str2 to replace "CS" with
//
str = str2.replace("CS", "SE");
75
60
61
"SE" and assign the return value to str
76
62
77
System.out.println("Expected: CS46A");
63
78
64
79
// Step 18: Display strl on a line
65
// Step 15: Display str on a line
80
66
81
System.out.println(str);
System.out.println("Expected: SE 46A");
67
82
System.out.println("Expected: Java");
68
83
69
84
// Step 19: Display str2 on a line
// Step 16: Call method replace() on str2 to replace" with
//
70
85
71
*" and assign the return value to str
86
72
87
System.out.println("Expected: CS 46A");
73
88
74
// Step 17: Display str on a line
89 )
75
90
76
77
System.out.printin("Expected: C546A");-
78
MacBook Air
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 2 steps
![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