SlideShare a Scribd company logo
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.pdf
xlynettalampleyxc
 
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.docx
EvandWYAlland
 
@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
aplolomedicalstoremr
 
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
duttakajal70
 
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
forwardcom41
 
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
Amansupan
 
Speed up the mobile development process
Speed up the mobile development processSpeed up the mobile development process
Speed up the mobile development process
LeonardoSarra
 
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
 
C# 3.5 Features
C# 3.5 FeaturesC# 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
info961251
 
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
irshadoptical
 
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
arjuncp10
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEm
home
 
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
normanibarber20063
 
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
nipuns1983
 
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
amritashinfosalys
 
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
anandshingavi23
 
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
mhande899
 
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
premkhatri99
 

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.pdf
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 
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
omarionmatzmcwill497
 

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

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 

Recently uploaded (20)

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 

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