1 / 5100%
Lab Topic: Strings
Working on "String" class and some of its methods.
Familiarization with basic data types.
Using the Scanner Class
Printing output
Find the correct way of string comparisons.
Getting familiar with Control Statements (If, else)
Problem Description
You will have to write a Java program that asks the user to enter two strings, firstname and
lastname, and concatenates the strings to make a full name. The program will use methods of class
String” like length () and toUpperCase() on the full name and compare strings by equals() method
and if-else statements.
Sample Output
Below is an example of what your output should roughly look like when this lab is completed.
The red text are user inputs.
Note: When the program runs in submission system, you will NOT see any input like the red text
above. If you use print to show prompts, your output might be on the same line. To avoid this
issue, please use println instead of print to show the prompts.
Sample Run 1:
Please enter first name: magnus
Please enter last name: carlsen
Full name (in capitals): MAGNUS CARLSEN
Length of full name: 14
String comparison using "==" sign does NOT work
String comparison using "equals" method works
Sample Run 2:
Please enter first name: wesley
Please enter last name: so
Full name (in capitals): WESLEY SO
Length of full name: 9
String comparison using "==" sign does NOT work
String comparison using "equals" method works
CSE 110 - Lab 2