Add the following methods to your Name class: a. A method that accepts no parameters and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Add the following methods to your Name class: a. A method that accepts no parameters and returns the length of the name, i.e., the sum of the lengths of the three parts of the name. b. A method that accepts no parameters and returns a String consisting of the three initials IN UPPERCASE. c. A method that accepts an integer n and returns the nth character in the full three part name. d. A method that accepts no parameters and returns a String consisting of the last name followed by a comma followed by the first name followed by the middle name. Remember to put spaces between the names. e. A method that accepts a String and returns true if the String is equal to the first name (use the equals method in the String class!). This is not quite the proper way to define an equals() method, as we will learn later. f. A method that accepts a Name object and returns true if the three parts of the name object are the same as the three parts of "this" Name object. 4. Create a class called Name Driver which contains a main method. Inside the main method, instantiate a Name object using your name and test your methods to make sure they work. Does it work for all names? private String firstName; /** *Middle name. */ private String middleName; /** * Last name */ private String lastName; //Constructor /** * @param args */ public Name (String firstname, String middlename, String lastname) { firstName = firstname; middleName = middlename; last Name lastname; } //getters //get First Name public String getFirstName () { return firstName; } //get middle name public String getMiddleName() { return middleName; } //get last name public String getLastName() { return lastName; } //setters public void setFirstNmae (String firstname) { this.firstName = firstname; } public void setMiddleNmae (String middlename) { this.middleName = middlename; } public void setLastName (String lastname) { this.lastName = lastname; } Add the following methods to your Name class: a. A method that accepts no parameters and returns the length of the name, i.e., the sum of the lengths of the three parts of the name. b. A method that accepts no parameters and returns a String consisting of the three initials IN UPPERCASE. c. A method that accepts an integer n and returns the nth character in the full three part name. d. A method that accepts no parameters and returns a String consisting of the last name followed by a comma followed by the first name followed by the middle name. Remember to put spaces between the names. e. A method that accepts a String and returns true if the String is equal to the first name (use the equals method in the String class!). This is not quite the proper way to define an equals() method, as we will learn later. f. A method that accepts a Name object and returns true if the three parts of the name object are the same as the three parts of "this" Name object. 4. Create a class called Name Driver which contains a main method. Inside the main method, instantiate a Name object using your name and test your methods to make sure they work. Does it work for all names? private String firstName; /** *Middle name. */ private String middleName; /** * Last name */ private String lastName; //Constructor /** * @param args */ public Name (String firstname, String middlename, String lastname) { firstName = firstname; middleName = middlename; last Name lastname; } //getters //get First Name public String getFirstName () { return firstName; } //get middle name public String getMiddleName() { return middleName; } //get last name public String getLastName() { return lastName; } //setters public void setFirstNmae (String firstname) { this.firstName = firstname; } public void setMiddleNmae (String middlename) { this.middleName = middlename; } public void setLastName (String lastname) { this.lastName = lastname; }
Expert Answer:
Related Book For
Using Financial Accounting Information The Alternative to Debits and Credits
ISBN: 978-1133161646
7th Edition
Authors: Gary A. Porter, Curtis L. Norton
Posted Date:
Students also viewed these programming questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Arvind runs a small electronics company in India and has just sold some equipment to a U.S. company for $1 million to be paid in 90 days. His cost in Indian Rupees (INR) is 60 million. The current...
-
As much as Americans try to avoid high fat, high calorie foods, the demand for a cold, creamy ice cream cone on a hot day is hard to resist. The popular ice cream franchise Coldstone Creamery posted...
-
Six years ago, Miguel invested $3,500. Today his investment is worth $5659. The internal rate of return on this investment is A) -7.69%. B) error 5. C) 8.34%. D) 10.28%. Please show formula and...
-
Compare and contrast components to objects.
-
Weatherly Lumber Company processes wood pulp for manufacturing various paper products. The company employs a process costing system for its manufacturing operations. All direct materials are added at...
-
Using the logic gates and Multisim test whether the following Boolean expression is valid or AB + BC + CA = AB + BC + C not. Verify your simulation with hand calculation by applying Boolean theorems...
-
The demand and supply functions for two supplementary products, cups (X) and plates (Y), are given as: 9dx = 246-9px +3py; 9,X = -15 + 45px and 94Y - 275 + 6px - 12py ; 9sY 1896py. Determine the...
-
Why might an investor-owned firm choose to issue different classes of common stock?
-
What are the implications of portfolio theory for investors?
-
a. What is the preemptive right? b. Why is it important to shareholders?
-
Explain why holding investments in portfolios has such a profound impact on the concept of financial risk.
-
Explain the risk/return trade-off.
-
You can place both TCP/IP clients and servers and IPX clients and servers on the same Ethernet network, and each client will talk to its server. How do you think this is possible?
-
The rate at which the temperature of an object changes is proportional to the difference between its own temperature and the temperature of the surrounding medium. Express this rate as a function of...
-
If the angle between vectors \(\vec{A}\) and \(\vec{B}\) is \(110^{\circ}\) and if \(A=1.7 \mathrm{~N}\) and \(B=2.0 \mathrm{~m}\), what is the value of \(\vec{A} \cdot \vec{B}\) ?
-
You throw a textbook to a friend who is at their dormitory window \(2.2 \mathrm{~m}\) above you. You are standing \(4.0 \mathrm{~m}\) away from the building and your throw is perfectly made such that...
-
A force \(\vec{F}=F_{x} \hat{\imath}+F_{y} \hat{\jmath}\) with \(F_{x}=50 \mathrm{~N}\) and \(F_{y}=12 \mathrm{~N}\) is exerted on a particle as the particle moves along the \(x\) axis from \(x=1.0...
Study smarter with the SolutionInn App