Question: Lab1 Write a class, StringLab1 ( with a main method. Include the following: o Declare a String variable in your class. The content of the
Lab1
Write a class, StringLab1 (with a main method. Include the following:
o Declare a String variable in your class. The content of the String is Abcd University
Using the String and the methods of the String class, print the following lines (you do not have to print the line numbers at the beginning of each line; they are there so I can show you want method I want you to use in the next section).
The number of characters is 15
The String in lower case is abcd university
The String in upper case is ABCD UNIVERSITY
The first 6 characters of the String is Abcd U
The rest of the characters in the String are University
The U in the String is at position 5
The u in the String is at position -1
The o in the String is at position -1
A new String where University is replaced with U Abcd U
The original String has not changed Abcd University
For each line use the methods to the right of the line:
The number of characters is 15 (length)
The String in lower case is abcd university(toLowerCase)
The String in upper case is ABCD UNIVERSITY (toUpperCase)
The first 6 characters of the String is Abcd U(substring)
The rest of the characters in the String are University (substring)
The U in the String is at position 5 (indexOf)
The u in the String is at position -1 (indexOf)
The o in the String is at position -1 (indexOf)
A new String where University is replaced with U Abcd U(replace)
The original String has not changed Abcd University (none)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Lab2:
Write a class StringLab2 with a main method which does the following:
Asks the user for first name and then last name (2 separate inputs)
Using a Scanner gets the first name and last name
Using the methods of String, prints the initials in upper case
Generates a password which consists of the following concatenated and in lower case:
a. First 3 letters of the last name
b. Length of the first name
c. First 3 letters of the first name
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sample Run:
Enter the first name
Mary
Enter the last name
Jones
Your initials are: MJ
Your password will be jon4mar
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
