Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.*; class NameTest { public static void main(String [] args) { Scanner scan = new Scanner(System.in); // Request the first name System.out.print(Please enter a

import java.util.*;

class NameTest { public static void main(String [] args) { Scanner scan = new Scanner(System.in);

// Request the first name System.out.print("Please enter a name, First Middle Last: "); String f = scan.next(); String m = scan.next(); String l = scan.next(); Name name1 = new Name(f,m,l);

// Run all the methods. System.out.println("Each part: " + name1.getFirst() + " " + name1.getMiddle() + " " + name1.getLast()); System.out.println("FML: " + name1.firstMiddleLast()); System.out.println("LFM: " + name1.lastFirstMiddle()); System.out.println("Initials: " + name1.initials()); System.out.println("Length: " + name1.length()); System.out.println(); System.out.print("Enter a seond name for compare test, "+ "First Middle Last: "); f = scan.next(); m = scan.next(); l = scan.next(); Name name2 = new Name(f,m,l); System.out.println(name1.firstMiddleLast() + " same as " + name2.firstMiddleLast() + ": " + name1.equals(name2)); System.out.println(name2.firstMiddleLast() + " same as " + name1.firstMiddleLast() + ": " + name2.equals(name1)); System.out.println("(Of course, these results should be the same.)"); } }

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

Step: 3

blur-text-image

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Why Do People believe Weird Things? TED Talk.

Answered: 1 week ago