SlideShare a Scribd company logo
1 of 3
Download to read offline
Overview You are tasked with writing a program called Social Security that prompts the user to
enter the data (name and date-ofbirth)for a collection of people. The program will then process
this collection (array) of People (objects we create in another file) to determine who qualifies for
Social Security benefits. Specifications For our Social Security program we will need two java
files 1. Person java The person class which stores the data for a specific individual 2.
SocialSecurity.java (The driver) Details for these two class files appear below. Person ava UML
diagram name: String birthdate: LocalDate Person0 Person (newName: String, month: int, day:
int, year: int) NetName newName: String) void getName(): String set BirthDate month int, day:
int, year int) void get BirthDate 0 LocalDate toString(): String calculate Age(myBirth
LocalDate) int Person ava method description Two constructors 1. A Default constructor that
creates a Person whose name and birthdate are set to null. 2. A parameterized constructor that
accepts a String representation of the name, and three integers corresponding to the month, day,
and year in which the person was born. Setters and getters for the two instance variables. A
toString0 method that prints the person in the form dob
Solution
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;
class Person {
String name;
LocalDate birthdate;
public Person() {
super();
}
public Person(String name, int month, int day, int year) {
super();
this.name = name;
this.birthdate = LocalDate.of(year, month, day);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public LocalDate getBirthdate() {
return birthdate;
}
public void setBirthdate(int month, int day, int year) {
this.birthdate = LocalDate.of(year, month, day);
}
@Override
public String toString() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
birthdate.format(formatter);
return "Person [name=" + name + ", birthdate=" + birthdate + "]";
}
public int calculateAge() {
return Period.between(birthdate, LocalDate.now()).getYears();
}
public void qualifySSN() {
if(this.calculateAge()>66)
System.out.println("Qualifies for Social Security Benifits");
else
System.out.println("Doesnot qualifies for Social Security Benefits");
}
}
public class SocialSecurity {
public static void main(String[] args) {
if (args.length > 1)
System.out.println("Invalid number of command line arguments");
int num = Integer.parseInt(args[0]);
Person[] p = new Person[num];
Scanner in = new Scanner(System.in).useDelimiter(" ");
;
for (int i = 0; i < num; i++) {
System.out.println("enter persons name");
String name = in.next();
System.out.println("enter date of birth in the format Month Day Year");
String dob = in.next();
String[] temp = dob.split(" ");
p[i] = new Person(name, Integer.parseInt(temp[0]), Integer.parseInt(temp[1]),
Integer.parseInt(temp[2]));
}
for (int i = 0; i < num; i++) {
System.out.println(p[i].toString());
p[i].qualifySSN();
}
}
}

More Related Content

Similar to Overview You are tasked with writing a program called Social Security.pdf

In your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdfIn your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdf
arihanthtextiles
 
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
Codecamp Romania
 
In your Person classChange the visibility of all fields from priv.pdf
In your Person classChange the visibility of all fields from priv.pdfIn your Person classChange the visibility of all fields from priv.pdf
In your Person classChange the visibility of all fields from priv.pdf
aristogifts99
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10
Vince Vo
 
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 The Person Student Employee Faculty and Staff clas.pdf
Java The Person Student Employee Faculty and Staff clas.pdfJava The Person Student Employee Faculty and Staff clas.pdf
Java The Person Student Employee Faculty and Staff clas.pdf
adinathassociates
 
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
 
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
allwayscollection
 

Similar to Overview You are tasked with writing a program called Social Security.pdf (20)

In your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdfIn your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdf
 
15. DateTime API.ppt
15. DateTime API.ppt15. DateTime API.ppt
15. DateTime API.ppt
 
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
 
In your Person classChange the visibility of all fields from priv.pdf
In your Person classChange the visibility of all fields from priv.pdfIn your Person classChange the visibility of all fields from priv.pdf
In your Person classChange the visibility of all fields from priv.pdf
 
Rd
RdRd
Rd
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
 
Java™ (OOP) - Chapter 10: "Thinking in Objects"
Java™ (OOP) - Chapter 10: "Thinking in Objects"Java™ (OOP) - Chapter 10: "Thinking in Objects"
Java™ (OOP) - Chapter 10: "Thinking in Objects"
 
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 The Person Student Employee Faculty and Staff clas.pdf
Java The Person Student Employee Faculty and Staff clas.pdfJava The Person Student Employee Faculty and Staff clas.pdf
Java The Person Student Employee Faculty and Staff clas.pdf
 
enum_comp_exercicio01.docx
enum_comp_exercicio01.docxenum_comp_exercicio01.docx
enum_comp_exercicio01.docx
 
New Java Date/Time API
New Java Date/Time APINew Java Date/Time API
New Java Date/Time API
 
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
 
Creating a Facebook Clone - Part XX - Transcript.pdf
Creating a Facebook Clone - Part XX - Transcript.pdfCreating a Facebook Clone - Part XX - Transcript.pdf
Creating a Facebook Clone - Part XX - Transcript.pdf
 
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
 
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
 
10slide.ppt
10slide.ppt10slide.ppt
10slide.ppt
 
Computer programming 2 Lesson 14
Computer programming 2  Lesson 14Computer programming 2  Lesson 14
Computer programming 2 Lesson 14
 
11. Objects and Classes
11. Objects and Classes11. Objects and Classes
11. Objects and Classes
 
Java Foundations: Objects and Classes
Java Foundations: Objects and ClassesJava Foundations: Objects and Classes
Java Foundations: Objects and Classes
 

More from info961251

With which portion of an epithelial cell in the stomach would food be.pdf
With which portion of an epithelial cell in the stomach would food be.pdfWith which portion of an epithelial cell in the stomach would food be.pdf
With which portion of an epithelial cell in the stomach would food be.pdf
info961251
 
Which of the following correctly states the functions of the roug.pdf
Which of the following correctly states the functions of the roug.pdfWhich of the following correctly states the functions of the roug.pdf
Which of the following correctly states the functions of the roug.pdf
info961251
 
What is the definition of the words, and state the diffe.pdf
What is the definition of the words, and state the diffe.pdfWhat is the definition of the words, and state the diffe.pdf
What is the definition of the words, and state the diffe.pdf
info961251
 
TB is a major worldwide disease with new cases arising at an alarmin.pdf
TB is a major worldwide disease with new cases arising at an alarmin.pdfTB is a major worldwide disease with new cases arising at an alarmin.pdf
TB is a major worldwide disease with new cases arising at an alarmin.pdf
info961251
 
Question 1Theories of Law Subject__________ is a collaborative.pdf
Question 1Theories of Law Subject__________ is a collaborative.pdfQuestion 1Theories of Law Subject__________ is a collaborative.pdf
Question 1Theories of Law Subject__________ is a collaborative.pdf
info961251
 
Please fix the java code (using eclipse)package hw4p1;import jav.pdf
Please fix the java code (using eclipse)package hw4p1;import jav.pdfPlease fix the java code (using eclipse)package hw4p1;import jav.pdf
Please fix the java code (using eclipse)package hw4p1;import jav.pdf
info961251
 
A geneticist Dr. O. Sophila discovers a new mutation that causes the .pdf
A geneticist Dr. O. Sophila discovers a new mutation that causes the .pdfA geneticist Dr. O. Sophila discovers a new mutation that causes the .pdf
A geneticist Dr. O. Sophila discovers a new mutation that causes the .pdf
info961251
 

More from info961251 (20)

With which portion of an epithelial cell in the stomach would food be.pdf
With which portion of an epithelial cell in the stomach would food be.pdfWith which portion of an epithelial cell in the stomach would food be.pdf
With which portion of an epithelial cell in the stomach would food be.pdf
 
Write the interface (.h file) of a class Accumulator containing A d.pdf
Write the interface (.h file) of a class Accumulator containing  A d.pdfWrite the interface (.h file) of a class Accumulator containing  A d.pdf
Write the interface (.h file) of a class Accumulator containing A d.pdf
 
You are carrying out PCRs in lab. Why do you not need helicase, SSB,.pdf
You are carrying out PCRs in lab. Why do you not need helicase, SSB,.pdfYou are carrying out PCRs in lab. Why do you not need helicase, SSB,.pdf
You are carrying out PCRs in lab. Why do you not need helicase, SSB,.pdf
 
Write your own definition of cloning. No plagarism!SolutionClo.pdf
Write your own definition of cloning. No plagarism!SolutionClo.pdfWrite your own definition of cloning. No plagarism!SolutionClo.pdf
Write your own definition of cloning. No plagarism!SolutionClo.pdf
 
Write appropriate SQL DDL statements (Create Table Statements) for d.pdf
Write appropriate SQL DDL statements (Create Table Statements) for d.pdfWrite appropriate SQL DDL statements (Create Table Statements) for d.pdf
Write appropriate SQL DDL statements (Create Table Statements) for d.pdf
 
Write a class called Student that extends the provided Person class..pdf
Write a class called Student that extends the provided Person class..pdfWrite a class called Student that extends the provided Person class..pdf
Write a class called Student that extends the provided Person class..pdf
 
why NADH and FADH2 are a type of energy currencySolutionEnergy.pdf
why NADH and FADH2 are a type of energy currencySolutionEnergy.pdfwhy NADH and FADH2 are a type of energy currencySolutionEnergy.pdf
why NADH and FADH2 are a type of energy currencySolutionEnergy.pdf
 
Who is D.L ShellSolutionHi friend,Donald L. Shell (March 1,.pdf
Who is D.L ShellSolutionHi friend,Donald L. Shell (March 1,.pdfWho is D.L ShellSolutionHi friend,Donald L. Shell (March 1,.pdf
Who is D.L ShellSolutionHi friend,Donald L. Shell (March 1,.pdf
 
Which of the following correctly states the functions of the roug.pdf
Which of the following correctly states the functions of the roug.pdfWhich of the following correctly states the functions of the roug.pdf
Which of the following correctly states the functions of the roug.pdf
 
What is isomerism How many kinds are there Define each kind and.pdf
What is isomerism How many kinds are there Define each kind and.pdfWhat is isomerism How many kinds are there Define each kind and.pdf
What is isomerism How many kinds are there Define each kind and.pdf
 
What is the definition of the words, and state the diffe.pdf
What is the definition of the words, and state the diffe.pdfWhat is the definition of the words, and state the diffe.pdf
What is the definition of the words, and state the diffe.pdf
 
Two sources of radio waves (call them 1 and 2) are separated by a dis.pdf
Two sources of radio waves (call them 1 and 2) are separated by a dis.pdfTwo sources of radio waves (call them 1 and 2) are separated by a dis.pdf
Two sources of radio waves (call them 1 and 2) are separated by a dis.pdf
 
Use the information in the table to select the image that represents .pdf
Use the information in the table to select the image that represents .pdfUse the information in the table to select the image that represents .pdf
Use the information in the table to select the image that represents .pdf
 
Triggers can only be used to update table values. PLSQL blocks have.pdf
Triggers can only be used to update table values.  PLSQL blocks have.pdfTriggers can only be used to update table values.  PLSQL blocks have.pdf
Triggers can only be used to update table values. PLSQL blocks have.pdf
 
TB is a major worldwide disease with new cases arising at an alarmin.pdf
TB is a major worldwide disease with new cases arising at an alarmin.pdfTB is a major worldwide disease with new cases arising at an alarmin.pdf
TB is a major worldwide disease with new cases arising at an alarmin.pdf
 
7. How did printing technology impact literacy and educationSol.pdf
7. How did printing technology impact literacy and educationSol.pdf7. How did printing technology impact literacy and educationSol.pdf
7. How did printing technology impact literacy and educationSol.pdf
 
Question 1Theories of Law Subject__________ is a collaborative.pdf
Question 1Theories of Law Subject__________ is a collaborative.pdfQuestion 1Theories of Law Subject__________ is a collaborative.pdf
Question 1Theories of Law Subject__________ is a collaborative.pdf
 
Q Describe the 2 types of homologs. (1) Orthologs (2) ParalogsS.pdf
Q Describe the 2 types of homologs. (1) Orthologs (2) ParalogsS.pdfQ Describe the 2 types of homologs. (1) Orthologs (2) ParalogsS.pdf
Q Describe the 2 types of homologs. (1) Orthologs (2) ParalogsS.pdf
 
Please fix the java code (using eclipse)package hw4p1;import jav.pdf
Please fix the java code (using eclipse)package hw4p1;import jav.pdfPlease fix the java code (using eclipse)package hw4p1;import jav.pdf
Please fix the java code (using eclipse)package hw4p1;import jav.pdf
 
A geneticist Dr. O. Sophila discovers a new mutation that causes the .pdf
A geneticist Dr. O. Sophila discovers a new mutation that causes the .pdfA geneticist Dr. O. Sophila discovers a new mutation that causes the .pdf
A geneticist Dr. O. Sophila discovers a new mutation that causes the .pdf
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
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
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
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.
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
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
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
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
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 

Overview You are tasked with writing a program called Social Security.pdf

  • 1. Overview You are tasked with writing a program called Social Security that prompts the user to enter the data (name and date-ofbirth)for a collection of people. The program will then process this collection (array) of People (objects we create in another file) to determine who qualifies for Social Security benefits. Specifications For our Social Security program we will need two java files 1. Person java The person class which stores the data for a specific individual 2. SocialSecurity.java (The driver) Details for these two class files appear below. Person ava UML diagram name: String birthdate: LocalDate Person0 Person (newName: String, month: int, day: int, year: int) NetName newName: String) void getName(): String set BirthDate month int, day: int, year int) void get BirthDate 0 LocalDate toString(): String calculate Age(myBirth LocalDate) int Person ava method description Two constructors 1. A Default constructor that creates a Person whose name and birthdate are set to null. 2. A parameterized constructor that accepts a String representation of the name, and three integers corresponding to the month, day, and year in which the person was born. Setters and getters for the two instance variables. A toString0 method that prints the person in the form dob Solution import java.time.LocalDate; import java.time.Period; import java.time.format.DateTimeFormatter; import java.util.Scanner; class Person { String name; LocalDate birthdate; public Person() { super(); } public Person(String name, int month, int day, int year) { super(); this.name = name; this.birthdate = LocalDate.of(year, month, day); } public String getName() { return name; } public void setName(String name) {
  • 2. this.name = name; } public LocalDate getBirthdate() { return birthdate; } public void setBirthdate(int month, int day, int year) { this.birthdate = LocalDate.of(year, month, day); } @Override public String toString() { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy"); birthdate.format(formatter); return "Person [name=" + name + ", birthdate=" + birthdate + "]"; } public int calculateAge() { return Period.between(birthdate, LocalDate.now()).getYears(); } public void qualifySSN() { if(this.calculateAge()>66) System.out.println("Qualifies for Social Security Benifits"); else System.out.println("Doesnot qualifies for Social Security Benefits"); } } public class SocialSecurity { public static void main(String[] args) { if (args.length > 1) System.out.println("Invalid number of command line arguments"); int num = Integer.parseInt(args[0]); Person[] p = new Person[num]; Scanner in = new Scanner(System.in).useDelimiter(" "); ; for (int i = 0; i < num; i++) { System.out.println("enter persons name"); String name = in.next();
  • 3. System.out.println("enter date of birth in the format Month Day Year"); String dob = in.next(); String[] temp = dob.split(" "); p[i] = new Person(name, Integer.parseInt(temp[0]), Integer.parseInt(temp[1]), Integer.parseInt(temp[2])); } for (int i = 0; i < num; i++) { System.out.println(p[i].toString()); p[i].qualifySSN(); } } }