SlideShare a Scribd company logo
1 of 9
Download to read offline
I need help making these adjustments to my "class Persons_Information"
In your Person class:
Add a constant field to store the current year (review the Week 4 Lesson if you aren't sure how
to create a constant) :
Assign a value to the current year field when it is declared (do not add it to the constructors).
Add fields to store a person's age in years and how many years they have been with the college:
Do not add mutator or accessor methods for these fields.
Set the visibility modifier to private for these fields.
Modify both constructors to set default values for both fields.
Add processing actions:
Add a method to calculate a person's age in years only.
Add a method to calculate how long a person has been in college in years only.
Make both methods private.
Do not take any input or display any output in these methods.
Modify the toString() method:
Call the method to calculate the person's age.
Call the method to calculate how long the person has been in college.
Add the person's age to the String.
Add the person's time in college to the String.
Add output messages for each field so that the user knows what they are looking at.
Format the string using the new line escape sequence  so that each field and it's message is on a
separate line.
*** This is what I have so far.
48 class Persons_Information
49 {
50 private String personName;
51 private String currentAdress;
52 private String permanentAdress;
53 private int idNumber;
54 private String birthDate;
55 private int personAge;
56 private int entryYear;
57 private int totalYears;
58
59 public Persons_Information() {
60 personName = "";
61 currentAdress = "";
62 permanentAdress = "";
63 idNumber = 0;
64 birthDate = "";
65 personAge = 0;
66 entryYear = 0;
67 totalYears = 0;
68 }
69
70 public Persons_Information (int atIdNumber) {
71 idNumber = atIdNumber;
72 personName = "";
73 currentAdress = "";
74 permanentAdress = "";
75 birthDate = "";
76 personAge = 0;
77 entryYear = 0;
78 totalYears = 0;
79 }
80
81 //intput
82
83 public void setPersonName(String personName) {
84 this.personName = personName;
85 }
86
87 public void setCurrentAdress(String currentAdress) {
88 this.currentAdress = currentAdress;
89 }
90
91
92 public void setpermanentAdress(String permanentAdress) {
93 this.permanentAdress = permanentAdress;
94 }
95
96 public void setIdNumber(int id) {
97 idNumber = id;
98 }
99
100 public void setBirthDate(String birthDate) {
101 this.birthDate = birthDate;
102 }
103
104 public void setPersonAge(int pa) {
105 personAge = pa;
106 }
107
108 public void setEntryYear(int ey) {
109 entryYear = ey;
110 }
111
112 public void setTotalYears(int ty) {
113 totalYears = ty;
114 }
115
116 //output
117
118 public String getPersonName() {
119 return personName;
120 }
121
122 public String getCurrentAdress() {
123 return currentAdress;
124 }
125
126 public String getPermanentAdress() {
127 return permanentAdress;
128 }
129
130 public int getIdNumber() {
131 return idNumber;
132 }
133 public String getBirthDate() {
134 return birthDate;
135 }
136
137 public int getPersonAge() {
138 return personAge;
139 }
140
141 public int getEntryYear() {
142 return entryYear;
143 }
144
145 public int getTotalYears() {
146 return totalYears;
147 }
148
149 //toString
150
151 public String toString()
152 {
153 return "  Name:" + personName +
154 " Current Adress:" + currentAdress +
155 " Permanent Adress:" + permanentAdress +
156 " ID Number:" + idNumber +
157 " Birth Date" + birthDate +
158 " Age:" + personAge +
159 " Entry Year:" + entryYear +
160 " Total Years in System:" + totalYears;
161 }
162 }
163
Solution
solution
package com.prt.test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
class Persons_Information
{
public static final int CURRENT_YEAR = 2016;
private String personName;
private String currentAdress;
private String permanentAdress;
private int idNumber;
private String birthDate;
private int personAge;
private int entryYear;
private int totalYears;
private int yearsinCollege;
public Persons_Information() {
personName = "";
currentAdress = "";
permanentAdress = "";
idNumber = 0;
birthDate = "";
personAge = 0;
entryYear = 0;
totalYears = 0;
yearsinCollege = 0;
}
/**
* @param permanentAdress
* the permanentAdress to set
*/
public void setPermanentAdress(String permanentAdress) {
this.permanentAdress = permanentAdress;
}
public Persons_Information(int atIdNumber) {
idNumber = atIdNumber;
personName = "";
currentAdress = "";
permanentAdress = "";
birthDate = "";
personAge = 0;
entryYear = 0;
totalYears = 0;
yearsinCollege = 0;
}
// intput
public void setPersonName(String personName) {
this.personName = personName;
}
public void setCurrentAdress(String currentAdress) {
this.currentAdress = currentAdress;
}
public void setpermanentAdress(String permanentAdress) {
this.permanentAdress = permanentAdress;
}
public void setIdNumber(int id) {
idNumber = id;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public void setPersonAge(int pa) {
personAge = pa;
}
public void setEntryYear(int ey) {
entryYear = ey;
}
public void setTotalYears(int ty) {
totalYears = ty;
}
// output
public String getPersonName() {
return personName;
}
public String getCurrentAdress() {
return currentAdress;
}
public String getPermanentAdress() {
return permanentAdress;
}
public int getIdNumber() {
return idNumber;
}
public String getBirthDate() {
return birthDate;
}
public int getPersonAge() {
return personAge;
}
public int getEntryYear() {
return entryYear;
}
public int getTotalYears() {
return totalYears;
}
// toString
public String toString() {
return "  Name:" + personName + " Current Adress:" + currentAdress
+ " Permanent Adress:" + permanentAdress + " ID Number:"
+ idNumber + " Birth Date" + birthDate + " Age:"
+ personAge + " Entry Year:" + entryYear
+ " Total Years in System:" + totalYears;
}
private void calculatePersonAge() {
//initialization
int noofyears = 0;
Date convertedbirthdaydate, convertedCurrentdate = null;
Persons_Information in=new Persons_Information();
Date todaysDate = new Date();
Scanner scanner = new Scanner(System.in);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String currentdate = format.format(todaysDate);//to change current date in string
System.out
.println("enter your birthdate in only this format dd-mm-yyyy");
String birthdate = scanner.next();
String dateFormat1 = "dd-MM-yyyy";
String curdate = currentdate;
String dateFormat2 = "yyyy-MM-dd";
SimpleDateFormat format1 = new SimpleDateFormat(dateFormat1);
SimpleDateFormat format2 = new SimpleDateFormat(dateFormat2);
SimpleDateFormat Year = new SimpleDateFormat("yyyy");//to change the year format
try {
convertedbirthdaydate = (Date) format1.parse(birthdate);
convertedCurrentdate = (Date) format2.parse(curdate);
int year1 = Integer.parseInt(Year.format(convertedbirthdaydate));
// int year2 = Integer.parseInt(Year.format(convertedCurrentdate));
int year2 = CURRENT_YEAR;
noofyears = year2 - year1;
} catch (ParseException ex) {
System.out.println("invalid date format enter given format");
calculatePersonAge();
}
System.out.println("no of years" + noofyears);
}
private void getYearsInCollege()
{
Persons_Information in = new Persons_Information();
Scanner scanner=new Scanner(System.in);
System.out.println("enter entry year in your college ");
in.setEntryYear(scanner.nextInt());
int years = CURRENT_YEAR - (in.getEntryYear());
System.out.println("no of years in college" + years);
}
public static void main(String[] args) {
Persons_Information in = new Persons_Information();
in.calculatePersonAge();
in.getYearsInCollege();
}
}
output
enter your birthdate in only this format dd-mm-yyyy
02-06-1988
no of years28
enter entry year in your college
2010
no of years in college6

More Related Content

Similar to I need help making these adjustments to my class Persons_Informati.pdf

Here is the Person Class ProvidedUse the following filesPerson.pdf
Here is the Person Class ProvidedUse the following filesPerson.pdfHere is the Person Class ProvidedUse the following filesPerson.pdf
Here is the Person Class ProvidedUse the following filesPerson.pdfxlynettalampleyxc
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
main-cpp file #include -iostream- #include -vector- #include -Date-h.docx
main-cpp file #include -iostream- #include -vector-   #include -Date-h.docxmain-cpp file #include -iostream- #include -vector-   #include -Date-h.docx
main-cpp file #include -iostream- #include -vector- #include -Date-h.docxEvandWYAlland
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdfaplolomedicalstoremr
 
Hello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdfHello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdfduttakajal70
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfforwardcom41
 
Can someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfCan someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfAmansupan
 
Speed up the mobile development process
Speed up the mobile development processSpeed up the mobile development process
Speed up the mobile development processLeonardoSarra
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo....NET Conf UY
 
Overview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdfOverview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdfinfo961251
 
i need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdfi need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdfirshadoptical
 
public class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfpublic class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfarjuncp10
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmhome
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxnormanibarber20063
 
package employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfpackage employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfnipuns1983
 
I need help for my next project due next tuesday can you help me in .pdf
I need help for my next project due next tuesday can you help me in .pdfI need help for my next project due next tuesday can you help me in .pdf
I need help for my next project due next tuesday can you help me in .pdfamritashinfosalys
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfanandshingavi23
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdfmhande899
 
Please find my solution.Please let me know in case of any issue..pdf
Please find my solution.Please let me know in case of any issue..pdfPlease find my solution.Please let me know in case of any issue..pdf
Please find my solution.Please let me know in case of any issue..pdfpremkhatri99
 

Similar to I need help making these adjustments to my class Persons_Informati.pdf (20)

Here is the Person Class ProvidedUse the following filesPerson.pdf
Here is the Person Class ProvidedUse the following filesPerson.pdfHere is the Person Class ProvidedUse the following filesPerson.pdf
Here is the Person Class ProvidedUse the following filesPerson.pdf
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
main-cpp file #include -iostream- #include -vector- #include -Date-h.docx
main-cpp file #include -iostream- #include -vector-   #include -Date-h.docxmain-cpp file #include -iostream- #include -vector-   #include -Date-h.docx
main-cpp file #include -iostream- #include -vector- #include -Date-h.docx
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
Hello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdfHello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdf
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
 
Can someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfCan someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdf
 
Speed up the mobile development process
Speed up the mobile development processSpeed up the mobile development process
Speed up the mobile development process
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
 
C# 3.5 Features
C# 3.5 FeaturesC# 3.5 Features
C# 3.5 Features
 
Overview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdfOverview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdf
 
i need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdfi need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdf
 
public class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfpublic class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdf
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEm
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
 
package employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfpackage employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdf
 
I need help for my next project due next tuesday can you help me in .pdf
I need help for my next project due next tuesday can you help me in .pdfI need help for my next project due next tuesday can you help me in .pdf
I need help for my next project due next tuesday can you help me in .pdf
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdf
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdf
 
Please find my solution.Please let me know in case of any issue..pdf
Please find my solution.Please let me know in case of any issue..pdfPlease find my solution.Please let me know in case of any issue..pdf
Please find my solution.Please let me know in case of any issue..pdf
 

More from omarionmatzmcwill497

CenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdfCenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdfomarionmatzmcwill497
 
Are silenced genes associated with high or low levels of DNA methyla.pdf
Are silenced genes associated with high or low levels of DNA methyla.pdfAre silenced genes associated with high or low levels of DNA methyla.pdf
Are silenced genes associated with high or low levels of DNA methyla.pdfomarionmatzmcwill497
 
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdfA south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdfomarionmatzmcwill497
 
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdfWrite an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdfomarionmatzmcwill497
 
Write a program that will prompt a user to input their name(first .pdf
Write a program that will prompt a user to input their name(first .pdfWrite a program that will prompt a user to input their name(first .pdf
Write a program that will prompt a user to input their name(first .pdfomarionmatzmcwill497
 
With a blow count of 14 the density of the soil is Select one 15e bit.pdf
With a blow count of 14 the density of the soil is Select one 15e bit.pdfWith a blow count of 14 the density of the soil is Select one 15e bit.pdf
With a blow count of 14 the density of the soil is Select one 15e bit.pdfomarionmatzmcwill497
 
Which process(es) can move solutes against concentration gradients (.pdf
Which process(es) can move solutes against concentration gradients (.pdfWhich process(es) can move solutes against concentration gradients (.pdf
Which process(es) can move solutes against concentration gradients (.pdfomarionmatzmcwill497
 
What role do piRNAs play Serve as atemplate for transposon silencin.pdf
What role do piRNAs play  Serve as atemplate for transposon silencin.pdfWhat role do piRNAs play  Serve as atemplate for transposon silencin.pdf
What role do piRNAs play Serve as atemplate for transposon silencin.pdfomarionmatzmcwill497
 
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdfwhat was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdfomarionmatzmcwill497
 
Three LR circuits are made with the same resistor but different induc.pdf
Three LR circuits are made with the same resistor but different induc.pdfThree LR circuits are made with the same resistor but different induc.pdf
Three LR circuits are made with the same resistor but different induc.pdfomarionmatzmcwill497
 
There are several things fundamentally wrong in this illustration. Po.pdf
There are several things fundamentally wrong in this illustration. Po.pdfThere are several things fundamentally wrong in this illustration. Po.pdf
There are several things fundamentally wrong in this illustration. Po.pdfomarionmatzmcwill497
 
The poor are available to do the unpleasant jobs that no one .pdf
The poor are available to do the unpleasant jobs that no one .pdfThe poor are available to do the unpleasant jobs that no one .pdf
The poor are available to do the unpleasant jobs that no one .pdfomarionmatzmcwill497
 
Suppose that 14 of people are left handed. If you pick two people a.pdf
Suppose that 14 of people are left handed. If you pick two people a.pdfSuppose that 14 of people are left handed. If you pick two people a.pdf
Suppose that 14 of people are left handed. If you pick two people a.pdfomarionmatzmcwill497
 
Please help me with these General Biology 1 (Bio 111) questions. You.pdf
Please help me with these General Biology 1 (Bio 111) questions. You.pdfPlease help me with these General Biology 1 (Bio 111) questions. You.pdf
Please help me with these General Biology 1 (Bio 111) questions. You.pdfomarionmatzmcwill497
 
NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdf
NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdfNEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdf
NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdfomarionmatzmcwill497
 
Problem 14. Your probability class has 250 undergraduate students and.pdf
Problem 14. Your probability class has 250 undergraduate students and.pdfProblem 14. Your probability class has 250 undergraduate students and.pdf
Problem 14. Your probability class has 250 undergraduate students and.pdfomarionmatzmcwill497
 
Simplify each expression. Write all ansers without using negative ex.pdf
Simplify each expression. Write all ansers without using negative ex.pdfSimplify each expression. Write all ansers without using negative ex.pdf
Simplify each expression. Write all ansers without using negative ex.pdfomarionmatzmcwill497
 
Our understanding of genetic inheritance and the function of DNA i.pdf
Our understanding of genetic inheritance and the function of DNA i.pdfOur understanding of genetic inheritance and the function of DNA i.pdf
Our understanding of genetic inheritance and the function of DNA i.pdfomarionmatzmcwill497
 
Please Explain. Compute the worst case time complexity of the follow.pdf
Please Explain. Compute the worst case time complexity of the follow.pdfPlease Explain. Compute the worst case time complexity of the follow.pdf
Please Explain. Compute the worst case time complexity of the follow.pdfomarionmatzmcwill497
 
3. Variance of exponential and uniform distributions(a) Compute Va.pdf
3. Variance of exponential and uniform distributions(a) Compute Va.pdf3. Variance of exponential and uniform distributions(a) Compute Va.pdf
3. Variance of exponential and uniform distributions(a) Compute Va.pdfomarionmatzmcwill497
 

More from omarionmatzmcwill497 (20)

CenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdfCenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdf
 
Are silenced genes associated with high or low levels of DNA methyla.pdf
Are silenced genes associated with high or low levels of DNA methyla.pdfAre silenced genes associated with high or low levels of DNA methyla.pdf
Are silenced genes associated with high or low levels of DNA methyla.pdf
 
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdfA south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
 
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdfWrite an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
 
Write a program that will prompt a user to input their name(first .pdf
Write a program that will prompt a user to input their name(first .pdfWrite a program that will prompt a user to input their name(first .pdf
Write a program that will prompt a user to input their name(first .pdf
 
With a blow count of 14 the density of the soil is Select one 15e bit.pdf
With a blow count of 14 the density of the soil is Select one 15e bit.pdfWith a blow count of 14 the density of the soil is Select one 15e bit.pdf
With a blow count of 14 the density of the soil is Select one 15e bit.pdf
 
Which process(es) can move solutes against concentration gradients (.pdf
Which process(es) can move solutes against concentration gradients (.pdfWhich process(es) can move solutes against concentration gradients (.pdf
Which process(es) can move solutes against concentration gradients (.pdf
 
What role do piRNAs play Serve as atemplate for transposon silencin.pdf
What role do piRNAs play  Serve as atemplate for transposon silencin.pdfWhat role do piRNAs play  Serve as atemplate for transposon silencin.pdf
What role do piRNAs play Serve as atemplate for transposon silencin.pdf
 
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdfwhat was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
 
Three LR circuits are made with the same resistor but different induc.pdf
Three LR circuits are made with the same resistor but different induc.pdfThree LR circuits are made with the same resistor but different induc.pdf
Three LR circuits are made with the same resistor but different induc.pdf
 
There are several things fundamentally wrong in this illustration. Po.pdf
There are several things fundamentally wrong in this illustration. Po.pdfThere are several things fundamentally wrong in this illustration. Po.pdf
There are several things fundamentally wrong in this illustration. Po.pdf
 
The poor are available to do the unpleasant jobs that no one .pdf
The poor are available to do the unpleasant jobs that no one .pdfThe poor are available to do the unpleasant jobs that no one .pdf
The poor are available to do the unpleasant jobs that no one .pdf
 
Suppose that 14 of people are left handed. If you pick two people a.pdf
Suppose that 14 of people are left handed. If you pick two people a.pdfSuppose that 14 of people are left handed. If you pick two people a.pdf
Suppose that 14 of people are left handed. If you pick two people a.pdf
 
Please help me with these General Biology 1 (Bio 111) questions. You.pdf
Please help me with these General Biology 1 (Bio 111) questions. You.pdfPlease help me with these General Biology 1 (Bio 111) questions. You.pdf
Please help me with these General Biology 1 (Bio 111) questions. You.pdf
 
NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdf
NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdfNEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdf
NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdf
 
Problem 14. Your probability class has 250 undergraduate students and.pdf
Problem 14. Your probability class has 250 undergraduate students and.pdfProblem 14. Your probability class has 250 undergraduate students and.pdf
Problem 14. Your probability class has 250 undergraduate students and.pdf
 
Simplify each expression. Write all ansers without using negative ex.pdf
Simplify each expression. Write all ansers without using negative ex.pdfSimplify each expression. Write all ansers without using negative ex.pdf
Simplify each expression. Write all ansers without using negative ex.pdf
 
Our understanding of genetic inheritance and the function of DNA i.pdf
Our understanding of genetic inheritance and the function of DNA i.pdfOur understanding of genetic inheritance and the function of DNA i.pdf
Our understanding of genetic inheritance and the function of DNA i.pdf
 
Please Explain. Compute the worst case time complexity of the follow.pdf
Please Explain. Compute the worst case time complexity of the follow.pdfPlease Explain. Compute the worst case time complexity of the follow.pdf
Please Explain. Compute the worst case time complexity of the follow.pdf
 
3. Variance of exponential and uniform distributions(a) Compute Va.pdf
3. Variance of exponential and uniform distributions(a) Compute Va.pdf3. Variance of exponential and uniform distributions(a) Compute Va.pdf
3. Variance of exponential and uniform distributions(a) Compute Va.pdf
 

Recently uploaded

Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 

Recently uploaded (20)

Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

I need help making these adjustments to my class Persons_Informati.pdf

  • 1. I need help making these adjustments to my "class Persons_Information" In your Person class: Add a constant field to store the current year (review the Week 4 Lesson if you aren't sure how to create a constant) : Assign a value to the current year field when it is declared (do not add it to the constructors). Add fields to store a person's age in years and how many years they have been with the college: Do not add mutator or accessor methods for these fields. Set the visibility modifier to private for these fields. Modify both constructors to set default values for both fields. Add processing actions: Add a method to calculate a person's age in years only. Add a method to calculate how long a person has been in college in years only. Make both methods private. Do not take any input or display any output in these methods. Modify the toString() method: Call the method to calculate the person's age. Call the method to calculate how long the person has been in college. Add the person's age to the String. Add the person's time in college to the String. Add output messages for each field so that the user knows what they are looking at. Format the string using the new line escape sequence so that each field and it's message is on a separate line. *** This is what I have so far. 48 class Persons_Information 49 { 50 private String personName; 51 private String currentAdress; 52 private String permanentAdress; 53 private int idNumber; 54 private String birthDate; 55 private int personAge; 56 private int entryYear; 57 private int totalYears; 58 59 public Persons_Information() {
  • 2. 60 personName = ""; 61 currentAdress = ""; 62 permanentAdress = ""; 63 idNumber = 0; 64 birthDate = ""; 65 personAge = 0; 66 entryYear = 0; 67 totalYears = 0; 68 } 69 70 public Persons_Information (int atIdNumber) { 71 idNumber = atIdNumber; 72 personName = ""; 73 currentAdress = ""; 74 permanentAdress = ""; 75 birthDate = ""; 76 personAge = 0; 77 entryYear = 0; 78 totalYears = 0; 79 } 80 81 //intput 82 83 public void setPersonName(String personName) { 84 this.personName = personName; 85 } 86 87 public void setCurrentAdress(String currentAdress) { 88 this.currentAdress = currentAdress; 89 } 90 91 92 public void setpermanentAdress(String permanentAdress) { 93 this.permanentAdress = permanentAdress; 94 } 95
  • 3. 96 public void setIdNumber(int id) { 97 idNumber = id; 98 } 99 100 public void setBirthDate(String birthDate) { 101 this.birthDate = birthDate; 102 } 103 104 public void setPersonAge(int pa) { 105 personAge = pa; 106 } 107 108 public void setEntryYear(int ey) { 109 entryYear = ey; 110 } 111 112 public void setTotalYears(int ty) { 113 totalYears = ty; 114 } 115 116 //output 117 118 public String getPersonName() { 119 return personName; 120 } 121 122 public String getCurrentAdress() { 123 return currentAdress; 124 } 125 126 public String getPermanentAdress() { 127 return permanentAdress; 128 } 129 130 public int getIdNumber() { 131 return idNumber;
  • 4. 132 } 133 public String getBirthDate() { 134 return birthDate; 135 } 136 137 public int getPersonAge() { 138 return personAge; 139 } 140 141 public int getEntryYear() { 142 return entryYear; 143 } 144 145 public int getTotalYears() { 146 return totalYears; 147 } 148 149 //toString 150 151 public String toString() 152 { 153 return " Name:" + personName + 154 " Current Adress:" + currentAdress + 155 " Permanent Adress:" + permanentAdress + 156 " ID Number:" + idNumber + 157 " Birth Date" + birthDate + 158 " Age:" + personAge + 159 " Entry Year:" + entryYear + 160 " Total Years in System:" + totalYears; 161 } 162 } 163 Solution solution
  • 5. package com.prt.test; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Scanner; class Persons_Information { public static final int CURRENT_YEAR = 2016; private String personName; private String currentAdress; private String permanentAdress; private int idNumber; private String birthDate; private int personAge; private int entryYear; private int totalYears; private int yearsinCollege; public Persons_Information() { personName = ""; currentAdress = ""; permanentAdress = ""; idNumber = 0; birthDate = ""; personAge = 0; entryYear = 0; totalYears = 0; yearsinCollege = 0; } /** * @param permanentAdress * the permanentAdress to set */ public void setPermanentAdress(String permanentAdress) { this.permanentAdress = permanentAdress; } public Persons_Information(int atIdNumber) {
  • 6. idNumber = atIdNumber; personName = ""; currentAdress = ""; permanentAdress = ""; birthDate = ""; personAge = 0; entryYear = 0; totalYears = 0; yearsinCollege = 0; } // intput public void setPersonName(String personName) { this.personName = personName; } public void setCurrentAdress(String currentAdress) { this.currentAdress = currentAdress; } public void setpermanentAdress(String permanentAdress) { this.permanentAdress = permanentAdress; } public void setIdNumber(int id) { idNumber = id; } public void setBirthDate(String birthDate) { this.birthDate = birthDate; } public void setPersonAge(int pa) { personAge = pa; } public void setEntryYear(int ey) { entryYear = ey; } public void setTotalYears(int ty) { totalYears = ty; } // output
  • 7. public String getPersonName() { return personName; } public String getCurrentAdress() { return currentAdress; } public String getPermanentAdress() { return permanentAdress; } public int getIdNumber() { return idNumber; } public String getBirthDate() { return birthDate; } public int getPersonAge() { return personAge; } public int getEntryYear() { return entryYear; } public int getTotalYears() { return totalYears; } // toString public String toString() { return " Name:" + personName + " Current Adress:" + currentAdress + " Permanent Adress:" + permanentAdress + " ID Number:" + idNumber + " Birth Date" + birthDate + " Age:" + personAge + " Entry Year:" + entryYear + " Total Years in System:" + totalYears; } private void calculatePersonAge() { //initialization int noofyears = 0; Date convertedbirthdaydate, convertedCurrentdate = null;
  • 8. Persons_Information in=new Persons_Information(); Date todaysDate = new Date(); Scanner scanner = new Scanner(System.in); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String currentdate = format.format(todaysDate);//to change current date in string System.out .println("enter your birthdate in only this format dd-mm-yyyy"); String birthdate = scanner.next(); String dateFormat1 = "dd-MM-yyyy"; String curdate = currentdate; String dateFormat2 = "yyyy-MM-dd"; SimpleDateFormat format1 = new SimpleDateFormat(dateFormat1); SimpleDateFormat format2 = new SimpleDateFormat(dateFormat2); SimpleDateFormat Year = new SimpleDateFormat("yyyy");//to change the year format try { convertedbirthdaydate = (Date) format1.parse(birthdate); convertedCurrentdate = (Date) format2.parse(curdate); int year1 = Integer.parseInt(Year.format(convertedbirthdaydate)); // int year2 = Integer.parseInt(Year.format(convertedCurrentdate)); int year2 = CURRENT_YEAR; noofyears = year2 - year1; } catch (ParseException ex) { System.out.println("invalid date format enter given format"); calculatePersonAge(); } System.out.println("no of years" + noofyears); } private void getYearsInCollege() { Persons_Information in = new Persons_Information(); Scanner scanner=new Scanner(System.in); System.out.println("enter entry year in your college ");
  • 9. in.setEntryYear(scanner.nextInt()); int years = CURRENT_YEAR - (in.getEntryYear()); System.out.println("no of years in college" + years); } public static void main(String[] args) { Persons_Information in = new Persons_Information(); in.calculatePersonAge(); in.getYearsInCollege(); } } output enter your birthdate in only this format dd-mm-yyyy 02-06-1988 no of years28 enter entry year in your college 2010 no of years in college6