write a program to imput name, age, and date of birth and displays using input method(streams and bufferr)
java Program
pls answer(urgent)
Answers
Answer:
import java.util.Date;
public class Person{
private String name;
private String address;
private Date dob;
public Person( ){
name = null;
address = null;
dob = null;
}
public Person(String nameValue, String newAddress, Date newDob){
name = nameValue;
address = newAddress;
dob = newDob;
}
public String getName(){
return name;
}
public void setName(String nameValue){
name = nameValue;
}
public int getAddress(){
return address;
}
public void setAddress(String newAddress){
address = newAddress;
}
public int getDateOfBirth(){
return dob;
}
public void setDateOfBirth(Date newDob){
dob = newDob;
}
public void print(){
System.out.println("Name: " + name);
System.out.println ("Date Of Birth: " + dob);
System.out.println ("Address: " + address);
}
}
Person Tester{
Person a = new Person();
a. set Name("John Smith");
a. set Date Of Birth (01/08/1985);??? - doesn't work
Explanation:
import java.util.Date;
public class Person{
private String name;
private String address;
private Date dob;
public Person( ){
name = null;
address = null;
dob = null;
}
public Person(String nameValue, String newAddress, Date newDob){
name = nameValue;
address = newAddress;
dob = newDob;
}
public String getName(){
return name;
}
public void setName(String nameValue){
name = nameValue;
}
public int getAddress(){
return address;
}
public void setAddress(String newAddress){
address = newAddress;
}
public int getDateOfBirth(){
return dob;
}
public void setDateOfBirth(Date newDob){
dob = newDob;
}
public void print(){
System.out.println("Name: " + name);
System.out.println ("Date Of Birth: " + dob);
System.out.println ("Address: " + address);
}
}
Person Tester{
Person a = new Person();
a. set Name("John Smith");
a. set Date Of Birth (01/08/1985);??? - doesn't work