Write a Java program where you: Design a class named CollegeApplicant that conta
ID: 3691324 • Letter: W
Question
Write a Java program where you:
Design a class named CollegeApplicant that contains the following data fields, constructor and methods
The data fields:
A private String data member for the applicant’s name
A private int data member for the year of the applicant was born
A private String data member for the college the applicant is applying to
A private, static, int data member numberOfApplicant that keeps track the number of CollegeApplicant objective created.
The constructor and other methods (8 methods in total):
A no-arg constructor that sets applicant’s name to “John Doe”, birth year to 1996, and the college to “Virginia State University”; increments the value of numberOfApplicant data member; and print the date and time the object is created (create a Date object and use toString method).
A arg constructor that accepts the applicant’s name, birth year, and college as arguments. These values should be assigned to the object’s data fields (use “this” key word); increments the value of numberOfApplicant data member; and print the date and time the object is created (create a Date object and use toString method).
Accessor (getter) and mutator (setter) methods for college member (2 methods).
Accessor (getter) methods for name, birth year, and numberOfApplicant (3 methods).
A method that calculate applicant’s age
1. Draw the UML diagram (refer to page 345 about the UML diagram, pay attention to ‘-’ and ‘+’ sings and use underline for the static member) for the CollegeApplicant class.
2. Implement the CollegeApplicant class.
3. Write a test program to
create a CollegeApplicant object with no-arg constructor and display (must implement a print method in the test program) all the data members in the object (name, year, college, number of object created).
create another CollegeApplicant object with arg constructor and display (invoke the print method) the data members. Then invokes mutator method to change the college name, invokes the calculate age method, and displays the data members in the object along with the applicant’s age.
Explanation / Answer
Answer for Question:
This below java program for created for CollegeApplicant Informaton.
1. Created constructor and default and parameterised.
2. Create settors and mutors.
Cpode is:
public class CollegeApplicant
{
private String Name;
private int year;
private String College;
private static int numberOfApplicant ;
CollegeApplicant()
{
Name = "john Doe";
year = 1996;
College = "VTU";
numberOfApplicant++;
}
CollegeApplicant(String Name, int year, int College)
{
this.Name = Name;
this.year = year;
this.College = College;
numberOfApplicant++;
}
void setName(String Name)
{
this.Name = Name;
}
String getName()
{
return Name;
}
void setYear(int year)
{
this.year = year;
}
int getYear()
{
return year;
}
void setCollege(String College)
{
this.College = College;
}
String getCollege()
{
return College;
}
void setnumberOfApplicant(int numberOfApplicant)
{
this.numberOfApplicant = numberOfApplicant;
}
int getnumberOfApplicant()
{
return numberOfApplicant;
}
void applicantAge()
{
int age;
for(int i = year; i <=2016 ; i++)
age++;
System.out.println("Applivcnt Age is :"+age);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.