Site Navigation

Site Search

CS 110: Lab 4

Learning Objectives

After completion of this lab, you should be able to

Work collaboratively as a pair programming team

All labs in CS 110 will be done as pair programming teams. Your partner for today's lab is listed in the table below:

Hebeler 203
Grader: Vinh Tran; Assistant: Daniel Carpenter
Team 1
Aguilar Jr, Jaime
Bloom, Thomas
Team 2
Amezcua Gutierrez, Edson
Cuddington, Chris
Team 3
Baird, Owen
Field, Sarah
Team 4
Berman, Jake
Hansen, Mitchell
Team 5
Coudriet, Blake
Hastings, Jake
Team 6
Erickson, Joel
Hogan, Martin
Team 7
Goeke, Maxwell
Ling, Nathan
Team 8
Harris, Alexander
Nash, Christopher
Team 9
Heflick, Liz
Olivares, Scott
Team 10
McCauley, Rylee
Shearer, Stetson
Team 11
Millard, Ryan
Wagster, Nathan
Team 12
Olden, Gregory
Smith, Stephanie
Team 13
Quayle, Weston
Akana, Chris
Team 14
Straub-Walden, Andy
Millard, Mikel
Team 15
Williamson, Sarah
Awan, Samara
Fill in: Barrett Wright, Matthew

Note: Partners will change every week.

You may wish to review basic pair programming guidelines before you begin.

You should change roles every 10 to 15 minutes.

Use String variables and string concatenation

  1. Write a Java program named NameMaker.java with the String variables firstName, middleName, lastName, and fullName
  2. Prompt the user to enter their first, middle, and last names and read the names from the keyboard
  3. Use string concatenation to set and display their fullName as firstName + a blank char + middleName + a blank char + lastName
Enter your first name: Edward
Enter your middle name: Michael
Enter your last name: Gellenbeck

Hello Edward Michael Gellenbeck

Change Pair Partner Roles

Change pair partner roles. The driver should become the navigator, the navigator should become the driver.

Use String methods

The Java String class has an abundance of methods you can use to manipulate strings in your program.

  1. Use String methods to
    • Display their initials (hint: use charAt(0))
    • Display their full name in all uppercase letters (hint: use toUpperCase())
    • Display their full name in all lowercase letters
    • Display the number of characters in their full name, including blank spaces (hint: use length())
Enter your first name: Edward
Enter your middle name: Michael
Enter your last name: Gellenbeck

Hello Edward Michael Gellenbeck

Your initials are EMG
Upper case is EDWARD MICHAEL GELLENBECK
Lower case is edward michael gellenbeck

Your full name has 25 characters

Change Pair Partner Roles

Change pair partner roles. The driver should become the navigator, the navigator should become the driver.

Use JOptionPane class for user input

Modify your program so that it uses JOptionPane to prompt for and read in input from the user.

input first name
input middle name
input last name

Keep the System.out.println code to display the output to the console.

Hello Edward Michael Gellenbeck

Your initials are EMG
Upper case is EDWARD MICHAEL GELLENBECK
Lower case is edward michael gellenbeck

Your full name has 25 characters

Change Pair Partner Roles

Change pair partner roles. The driver should become the navigator, the navigator should become the driver.

Use JOptionPane for user output

In addition to diplaying the user output to the jGRASP console window, add the code and use String concatenation to create the JOptionPane output shown below

output for optional challenge

Tip: Declare a String variable to hold the output string and use concatenation to build the lines of the output

 outputString = "Hello " + fullName +
                "\n\nYour initials are " + firstName.charAt(0) + and so on
 

Note: the JOptionPane output is in addition to the jGRASP console window output. Your program should produce duplicate output, one to the console window (using System.out.println) and one to the JOptionPane.

To Receive Credit

You are allowed to drop your lowest lab grade for the entire quarter.