The assignment question is: (problem2) My answer is : the superclass person subc
ID: 671441 • Letter: T
Question
The assignment question is: (problem2)
My answer is :
the superclass person
subclass baby and babyTest:
1) Am I right for the problem 2? I am not sure what "add a method newChild, which takes as parameter the name of the new child, and returns a new Person with that name " actually means.
2) for the last question of problem4.
"Read a double value and print it in the US style with commas in it (e.g., value 123456 prints as “123,456”). " how to achieve this?
1. Extend your class Person from Homework 06 to represent a person's mother and father (who are themselves Persons). Define getters and setters for these. Your test program for this class should create some Persons and arrange them in a "family tree." 2. Extend your class Person to add a method newchild, which takes as parameter the name of the new child, and returns a new Person with that name (and age 0, of course). Illustrate this method's use in your test program for the class. 3. Write a program that reads two strings (which may include spaces) from the user. Your program should then test whether the first string is equal to, starts with, ends with, or otherwise contains the second string. Note: The java.lang.String class has all the methods you neec. 4. Java's System.out is an instance of the java.io.Printstream class. This class has a very useful method: printf. Use this method to do the following: . Read an integer and a double value and print them separated by a space in one call to printf Print the value of Math.PI to three decimal places 123456 prints as "123,456") . Read a double value and print it in the US style with commas in it (e.g., valueExplanation / Answer
2. Scanner scn=new Scanner(System.in);
System.out.print("Enter the number: ");
int n=scn.nextInt();
Integer quantity = new Integer(n);
NumberFormat numFor=NumberFormat.getNumberInstance(Locale.US);
String nP=numFor.format(quantity);
System.out.println("Your number in US format: "+nP);
1. public person newChild(String nChild){
person p=new person(nChild,0,null);
return p;
}
this is the method they asked i think please comment for doubt
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.