SlideShare a Scribd company logo
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
 
15. DateTime API.ppt
15. DateTime API.ppt15. DateTime API.ppt
15. DateTime API.ppt
VISHNUSHANKARSINGH3
 
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
 
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 - Chapter10Vince Vo
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
BG Java EE Course
 
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"
Gouda Mando
 
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
 
enum_comp_exercicio01.docx
enum_comp_exercicio01.docxenum_comp_exercicio01.docx
enum_comp_exercicio01.docx
Michel Valentim
 
New Java Date/Time API
New Java Date/Time APINew Java Date/Time API
New Java Date/Time API
Juliet Nkwor
 
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
Codemotion
 
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
ShaiAlmog1
 
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
 
10slide.ppt
10slide.ppt10slide.ppt
10slide.ppt
MohammedNouh7
 
Computer programming 2 Lesson 14
Computer programming 2  Lesson 14Computer programming 2  Lesson 14
Computer programming 2 Lesson 14
MLG College of Learning, Inc
 
11. Objects and Classes
11. Objects and Classes11. Objects and Classes
11. Objects and Classes
Intro C# Book
 
Java Foundations: Objects and Classes
Java Foundations: Objects and ClassesJava Foundations: Objects and Classes
Java Foundations: Objects and Classes
Svetlin Nakov
 

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
 
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
info961251
 
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
info961251
 
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
info961251
 
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
info961251
 
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
info961251
 
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
info961251
 
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
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 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
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
 
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
info961251
 
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
info961251
 
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
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
 
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
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
 
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
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

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
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
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
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
 
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
 

Recently uploaded (20)

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
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
 
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
 

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(); } } }