Question: In Javaenhace the program base on the first one. 1. You are going to design (and code) a class called Name . The class Name

In Javaenhace the program base on the first one.

1. You are going to design (and code) a class called Name. The class Name will contain three properties:

  • first, the first name which is a String
  • initial, the middle initial, which is a single character.
  • last, the last name, which is a String

The class has three constructors:

  • A default constructor, which accepts no parameters, calls constructors for the first and last name and sets the initial equal to a blank space.
  • Two conversion constructors, one of which accepts two parameters (first and last name), the other accepting three parameters (first name, middle initial and last name). The constructor accepting two paraeters sets the middle initial equal to a blank space.

In addition to the constructors, the Name class has the following methods:

  • readName() - which prompts the user for first name, middle initial and last name and reads them in.
  • writeName() - which prints the first name, middle initial and last name with a blank separating them, but without a newline (Use System.out.print().)
  • equals(), which returns true if the names are the same, false otherwise (case should match as well).

Write another class complete with a main()that uses the new class that you wrote and demonstrates that these methods all work correctly.

2. In the last assignment, we created a class called Name. This time, we are going to add the following methods:

toString - which returns a String consisting of the name.

A copy constructor, which takes as its one parameter another object of class Name

precedes, which returns true if the object comes before the parameter

Create a main program that reads in three names and prints the name that is first in standard alphabetical order (by last name; if the last name is the same by first name; if both match by initial).

And create a program that reads in three names and prints them in the order in which they should appear. Hint: Write a method that takes all three names and returns the name that appears first, a method that takes all three names and returns the name that appears in last.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!