Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pat Smith and Kelly Jones are engaged. What are possible last name combinations for the married couple (listing Pat first)? 1. Run the program below

Pat Smith and Kelly Jones are engaged. What are possible last name combinations for the married couple (listing Pat first)?

1. Run the program below to see three possible married-couple names. Note the use of variable firstNames to hold both first names of the couple.

2. Extend the program to declare and use a variable lastName similarly. Note that the print statements are neater. Run the program again.

3. Extend the program to print two more options that abut the last names, as in SmithJones and JonesSmith. Run the program again.

import java.util.Scanner;

public class ShowMarriedNames { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String firstName1; String lastName1; String firstName2; String lastName2; String firstNames; // FIXME: Declare lastName System.out.println("What is the first person's first name?"); firstName1 = scnr.nextLine(); System.out.println("What is the first person's last name?"); lastName1 = scnr.nextLine();

System.out.println("What is the second person's first name?"); firstName2 = scnr.nextLine(); System.out.println("What is the second person's last name?"); lastName2 = scnr.nextLine();

System.out.println("Here are some common married-couple names:"); System.out.println(firstName1 + " " + lastName1 + " and " + firstName2 + " " + lastName2);

firstNames = firstName1 + " and " + firstName2; System.out.println(firstNames + " " + lastName1); System.out.println(firstNames + " " + lastName2); // FIXME: Use lastName variable similarly to firstNames variable System.out.println(firstNames + " " + lastName1 + "-" + lastName2); System.out.println(firstNames + " " + lastName2 + "-" + lastName1); // FIXME: Print two more options that abut the last names

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

What is the meaning and definition of E-Business?

Answered: 1 week ago