1. Write a class Name that stores a person’s first, middle, and last names and provides the following methods:
public Name(String first, String middle, String last)—constructor. The name should be stored in the case given; don’t convert to all upper or lower case.
public String getFirst()—returns the first name
public String getMiddle()—returns the middle name
public String getLast()—returns the last name
public String firstMiddleLast()—returns a string containing the person’s full name in order, e.g., "Mary Jane Smith".
public String lastFirstMiddle()—returns a string containing the person’s full name with the last name first followed by a comma, e.g., "Smith, Mary Jane".
public boolean equals(Name otherName)—returns true if this name is the same as otherName. Comparisons should not be case sensitive. (Hint: There is a String method equalsIgnoreCase that is just like the String method equals except it does not consider case in doing its comparison.)
public String initials()—returns the person’s initials (a 3-character string). The initials should be all in upper case, regardless of what case the name was entered in. (Hint: Instead of using charAt, use the substring method of String to get a string containing only the first letter—then you can upcase this one-letter string. See Figure 3.1 in the text for a description of the substring method.)
public int length()—returns the total number of characters in the full name, not including spaces.
2. Now write a program TestNames.java that prompts for and reads in two names from the user (you’ll need first, middle, and last for each), creates a Name object for each, and uses the methods of the Name class to do the following:
a. For each name, print
first-middle-last version
last-first-middle version
initials
length
b. Tell whether or not the names are the same.
Here is my code. I keep getting a method error with getFullName in the Name.java file. Please help me re-write the code to fix this issue.
//Name.java
public class Name
{
private String firstName, middleName, lastName, fullName;
public Name(String first, String middle, String last)
{
firstName = first;
middleName = middle;
lastName = last;
String fullName = firstName '+' middleName '+' lastName;
}
public String getFirst()
{
return firstName;
}
public String getMiddle()
{
return middleName;
}
public String getLast()
{
return lastName;
}
public String firstMiddleLast()
{
return firstName + ' ' + middleName + ' ' + lastName;
}
public String lastFirstMiddle()
{
return lastName + ", " + firstName + ' ' + middleName;
}
public boolean equals(Name otherName)
{
return fullName.equalsIgnoreCase(otherName.getFullName());
}
public String initials()
{
return firstName.toUpperCase().substring(0,1)
+ middleName.toUpperCase().substring(0,1)
+ lastName.toUpperCase().substring(0,1);
}
public int length()
{
return firstName.length() + middleName.length() + lastName.length();
}
}
//NameTester.java
import java.util.Scanner;
public class NameTester
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String firstName1 = new String();
String middleName1 = new String();
String lastName1 = new String();
String firstName2 = new String();
String middleName2 = new String();
String lastName2 = new String();
System.out.print("\nPlease enter a first name: ");
firstName1 = input.nextLine();
System.out.print("Please enter a middle name: ");
middleName1 = input.nextLine();
System.out.print("Please enter a last name: ");
lastName1 = input.nextLine();
Name name1 = new Name(firstName1, middleName1, lastName1);
System.out.print("\nPlease enter another first name: ");
firstName2 = input.nextLine();
System.out.print("Please enter another middle name: ");
middleName2 = input.nextLine();
System.out.print("Please enter another last name: ");
lastName2 = input.nextLine();
Name name2 = new Name(firstName2, middleName2, lastName2);
System.out.println();
System.out.println(name1.firstMiddleLast());
System.out.println(name2.firstMiddleLast());
System.out.println(name1.lastFirstMiddle());
System.out.println(name2.lastFirstMiddle());
System.out.println(name1.initials());
System.out.println(name2.initials());
System.out.println(name1.length());
System.out.println(name2.length());
if (name1.equals(name2))
System.out.println("The names are the same.");
else
System.out.println("The names are not the same.");
}
}

Answers

Answer 1

i dont know the answer lol thats too long

Explanation:


Related Questions

What is the only language that a computer can understand

Answers

Answer: Low-Level language is the only language which can be understood by the computer. Low-level language is also known as Machine Language. The machine language contains only two symbols 1 & 0. All the instructions of machine language are written in the form of binary numbers 1's & 0's.

Explanation:

Answer:

Machine Language (low level language)

Low-Level language is the only language which can be understood by the computer. Low-level language is also known as Machine Language. The machine language contains only two symbols 1 & 0. All the instructions of machine language are written in the form of binary numbers 1's & 0's.

During early recording, microphones picked up sound waves and turned them into electrical signals that carved a _______ into the vinyl. (6 letters)

WILL PICK YOU AS BRAINLIEST!


hint- NOT journalism

HURRY please

Answers

Answer:

Groove

Explanation:

There is not much to explain

In a program, write a method that accepts two arguments: an array of integers and a number n. The method should print all of the numbers in the array that are greater than the number n (in the order that they appear in the array, each on their own line).
In the same file, create a main method and call your function using the following data sets:
The array {1, 5, 10, 2, 4, -3, 6} and the number 3.
The array {10, 12, 15, 24} and the number 12.
My code:
public class LargerThanN
{
public static void print(int[] array,int n)
{
for(int i=0; i {
if (array[i]>n)
System.out.println(array[i]);
}
System.out.println();
}
public static void main(String[] args)
{
int[] array1 = {1,5,10,2,4,-3,6};
int num1=3;
print(array1,num1);
int[] array2 = {10, 12, 15, 24};
int num2 = 12;
print(array2, num2);
}
}
My programming lab does not want extra lines between the output. What am I doing wrong? How do I fix it?

Failed Test Run
The contents of your standard output is incorrect.
Attention: the difference between your stdout and the expected stdout is just a question of spacing.
Standard Output Hide Invisibles
Your Code's Actual Result:
Expected Result: 5
5 10
10 4
4 6
6
15 15
24 24

Answers

Answer:

move the System.out.println(); outside the for loop.

Explanation:

see picture. I shortened the main() method a bit, for fun.

Pls help I will get points and brainliest

Answers

Answer:

They are both types of interfaces.

Explanation:

Click the answer that includes the word "Interface" or "Interfaces"

Pls help will mark brainliest as soon as u awnser

Answers

Answer:

The answer is...

Explanation:

It is A or D I would go with D tho

Hope this helped

:)

In this exercise we will practice using loops to handle collections/containers. Your job is to write a program that asks the user to enter a sentence, then it counts and displays the occurrence of each letter.
Note: your program should count the letters without regard to case. For example, A and a are counted as the same.
Here is a sample run:
Enter a sentence: It's a very nice day today!
a: 3 times
c: 1 times
d: 2 times
e: 2 times
i: 2 times
n: 1 times
o: 1 times
r: 1 times
s: 1 times
t: 2 times
v: 1 times
y: 3 times
Notes:
The purpose of this problem is to practice using loops and collections/containers/strings.
Please make sure to submit a well-written program. Good identifier names, useful comments, and spacing will be some of the criteria that will be used when grading this assignment.
This assignment can be and must be solved using only the materials that have been discussed in class: loops, the index system, strings, lists and/or dictionaries. Do not look for or use alternative methods that have not been covered as part of this course.
How your program will be graded:
correctness: the program performs calculations correctly: 40%
complies with requirements (it properly uses loops, and containers/strings): 40%
code style: good variable names, comments, proper indentation and spacing : 20%
Language is python 3

Answers

Answer:

In Python:

chars = 'abcdefghijklmnopqrstuvwxyz'

letter = input("Sentence: ")

for i in range(len(chars)):

   count = 0

   for j in range(len(letter)):

       if chars[i] == letter[j].lower():

           count = count + 1

   if count > 0 :

       print(chars[i]+": "+str(count)+" times")

Explanation:

This initializes the characters of alphabet from a-z

chars = 'abcdefghijklmnopqrstuvwxyz'

This prompts the user for sentence

letter = input("Sentence: ")

This iterates through the initialized characters

for i in range(len(chars)):

This initializes count to 0

   count = 0

This iterates through the input sentence

   for j in range(len(letter)):

This compares the characters of the sentence with alphabet a-z

       if chars[i] == letter[j].lower():

If there is a match, count is incremented by 1

           count = count + 1

If there is an occurrence of character,

   if count > 0 :

The character and its count is printed

       print(chars[i]+": "+str(count)+" times")

In this exercise we have to use the knowledge of computational language in Python, so we have that code is:

It can be found in the attached image.

So, to make it easier, the code in Python can be found below:

chars = 'abcdefghijklmnopqrstuvwxyz'

letter = input("Sentence: ")

for i in range(len(chars)):

  count = 0

  for j in range(len(letter)):

      if chars[i] == letter[j].lower():

          count = count + 1

  if count > 0 :

      print(chars[i]+": "+str(count)+" times")

See more about python at brainly.com/question/26104476

what is volitile memory?

Answers

Answer:

do you mean volatile? Volatile memory is a type of storage whose contents are erased when the system's power is turned off or interrupted.

Explanation:

hope this helps have a good rest of your day :) ❤

Which of the following make up atoms? A. weight, mass, and gravity B. protons, electrons, and neutrons C. elements, compounds, and molecules D. matter, non-matter, and air pressure

Answers

Answer:

B

Explanation:

protons, electrons and neutrons

use a for loop to create a random forest model for each value of n estimators from 1 to 30;
• evaluate each model on both the training and validation sets using MAE;
• visualize the results by creating a plot of n estimators vs MAE for both the training and validation sets
After that you should answer the following questions:
• Which value of n estimators gives the best results?
• Explain how you decided that this value for n estimators gave the best results:
Why is the plot you created above not smooth?
• Was the result here better than the result of Part 1? Wha: % better or worse was it? in python

Answers

Answer:

nvndknnnnnnngjf

Explanation:

f4tyt5erfhhfr

Which of the following statements demonstrates the consequence of segregated medical
care?
A. Inequitable access to education and funding for Black doctors
B. Fewer predominately white medical schools being open to Black students
C. Both A and B
D. Neither A nor B

Answers

Answer:

C. Both A and B

Explanation:

Not only is inequitable access to education and funding for Black doctors a consequence of segregated medical care, it also resulted in less predominately white medical schools allowing Black students.

The statements that demonstrate the consequence of segregated medical care are both statements A and B. The correct option is C.

What is segregated medical care?

To distinguish or put apart from others or the general population. Segregated medical care has led to Black students being accepted into less primarily white medical institutions, which has resulted in unequal access to education and funding for Black professionals.

Black doctors have unequal access to education and funding. Less predominantly white medical colleges accept students of color.

Medical discrimination, racialized socioeconomic deprivation, and a segregated healthcare system all contribute to drastically different experiences in care for Black and White patients.

Therefore, the correct option is C. Both A and B.

To learn more about segregated medical care, refer to the link:

https://brainly.com/question/10812745

#SPJ6

Other Questions
What is the interest rate of the account? What is the balance after 10 years?Interest rate:%Balance after 10 years: $ What would be the right answer? A company produces a single product. Variable production costs are $13.40 per unit and variable selling and administrative expenses are $4.40 per unit. Fixed manufacturing overhead totals $50,000 and fixed selling and administration expenses total $54,000. Assuming a beginning inventory of zero, production of 5,400 units and sales of 4,300 units, the dollar value of the ending inventory under variable costing would be:_____.a. $14,740.b. $24,640.c. $19,580.d. $9,900. 30 pointsfrom President Truman's First Address to CongressApril 16, 1945Tragic fate has thrust upon us grave responsibilities. We must carry on. Our departed leader never looked backward. He looked forward andmoved forward. That is what he would want us to do. That is what America will do. So much blood has already been shed for the ideals which wecherish, and for which Franklin Delano Roosevelt lived and died, that we dare not permit even a momentary pause in the hard fight for victory.Today, the entire world is looking to America for enlightened leadership to peace and progress. Such a leadership requires vision, courage andtolerance. It can be provided only by a united nation deeply devoted to the highest ideals. With great humility I call upon all Americans to help mekeep our nation united in defense of those ideals which have been so eloquently proclaimed by Franklin Roosevelt. I want in turn to assure my fellowAmericans and all of those who love peace and liberty throughout the world that I will support and defend those ideals with all my strength and allmy heart. That is my duty and I shall not shirk it.So that there can be no possible misunderstanding, both Germany and Japan can be certain, beyond any shadow of a doubt, that America willcontinue the fight for freedom until no vestige of resistance remains! We are deeply conscious of the fact that much hard fighting is still ahead of us.Having to pay such a heavy price to make complete victory certain, America will never become a party to any plan for partial victory! To settle formerely another temporary respite would surely jeopardize the future security of all the world. Our demand has been, and it remains-UnconditionalSurrender!We will not traffic with the breakers of the peace on the terms of the peace. The responsibility for making of the peace-and it is a very graveresponsibility-must rest with the defenders of the peace. We are not unconscious of the dictates of humanity. We do not wish to see unnecessaryor unjustified suffering. But the laws of God and of man have been violated and the guilty must not go unpunished. Nothing shall shake ourdetermination to punish the war criminals even though we must pursue them to the ends of the earth. Lasting peace can never be secured if wepermit our dangerous opponents to plot future wars with impunity at any mountain retreat-however distant. In this shrinking world, it is futile toseek safety behind geographical barriers. Real security will be found only in law and in justice.Drag the tiles to the boxes to form correct pairs.What is the author's purpose of each paragraph in the address? Match the purpose to the correct paragraph number.Paragraph 2Paragraph 4Paragraph 3Paragraph 1PurposeParagraphto clarify that an end to the present world conflict can only come with completeallied victoryto promise uninterrupted continuation of the previous administration's dutiesand strugglesto warn that only the victors can dictate how peace is established and howjustice is carried outto remind all Americans to stay engaged in the effort to secure peace and libertyworldwide Zachary went to the store to buy some walnuts. The price per pound of the walnuts is$5.25 per pound and he has a coupon for $3.25 off the final amount. With thecoupon, how much would Zachary have to pay to buy 3 pounds of walnuts? Also,write an expression for the cost to buy p pounds of walnuts, assuming at least one pound is purchased.Cost of 3pounds:Cost of p Pounds: Puntos gratis para las personas que los necesitan Solo djame un chiste o una adivinanza Jackson lives near the ocean at sea level. In his state, the winters are mild and the summers are cool. This climate is influenced by water currents along his coast that are generally cold and moving toward the equator. What climate zone does Jackson live in? Approximately how many USA troops were killed in Vietnam war Select all of the compounds.Group of answer choiceswater (H2O)gold (Au)nitric acid (HNO3)cobalt (Co)oxygen (O2) Find the product of 3/5x15 Time in hours4Number of miles96Unit rate (miles per hour)12 || 123. Orlando is traveling at 12 miles per hour. a. **How many miles will he travel in 4 hours? Enter your answer in the table. b. *How long will it take him to travel 96 miles? Enter your answer in the table.NO WORK = NO CREDIT = REPORT On what basis did the federal government deal with Indian tribes when treaties were negotiatedA. The federal government signed treaties with Indian tribes as though they were enemies of the state.B. The federal government signed treaties with Indian tribes as though they were Americans.C. The federal government signed treaties with Indian tribes as though they were foreign nations within the borders of the United States.D.The federal government refused to sign treaties with Indian tribes since they were still a threat. Please Help. Im stuck on this question and i cant figure it out what is the relationship between adapt and climate Identify the tense of each boldfaced verb.By next week, I will have lived in Texas for two yearsPastPast perfect Past progressivePresentPresent perfect Future perfect Past perfect progressiveOr present progressive This year, Faaria's car is worth 22,000. If the value of Faaria's car decreases by 8%, what will her car be worth next year? Select the common noun(s).Lil Wayne finds happiness everywhere around him.Submit answerShow hint PLZ HELP ITS DUE TODAY Question 106.7 ptsWhich of the following most likely happens in the cells of a person running amarathon?The respiration rate increases to produce more ATP.The cell division rate increases to produce more muscle fibersThe photosynthesis rate increases to produce more sugarsThe replication rate increases to produce more DNA Can someone plz help me with this one problem plz!!