In: Computer Science
JAVA PROJECT USING NETBEANS
An application that keeps a record of family profiles in a city that are qualified in the program. Only one member of the family is allowed to apply for the SAP ( is a program/Organization) and that is the head of the family. Qualified families are those that belong to the poorest of the poor whose total daily earning is 550 or below per day. (Assume that the income is the only qualification. In reality there are more like senior citizens, indigent people, disabled persons, etc.)
Minimum Requirement:
The application/ program must be able to do the ff:
• process an application for the program which is the SAP. Make sure that the applicant is qualified and that there was no prior application made by any member of his family.
(OPTIONAL if you can only do this part) • generate a sorted list of all SAP (is a program/organization) beneficiaries in the city.
(OPTIONAL if you can only do this part) • generate a sorted list of SAP (is a program/organization) beneficiaries per family size.
(OPTIONAL if you can only do this part) • count the number of beneficiaries that earn less than 100 per day.
Hi,
It was long task to complete so i did what was possible in the gien timeframe.
1. Complted the reqgistration of SAP members
2. Count the total number of beneficiaries earn less than 100
I created total system which is based on user choices...user can register or can do other operations.
Choice number 1 and 4 and 5 are done in this program.
import java.util.ArrayList;
import java.util.Scanner;
public class SAPApplications {
public static void main(String[] args)
{
ArrayList<FamilyMember> memList = new ArrayList<FamilyMember>();
Scanner choice = new Scanner(System.in);
String input="";
System.out.println("############ Welcome To The SAP Member Registration System ############\n\n");
///// start while loop////////////
while(true){
System.out.println("########## Please choose below options: #############\n");
//user can choose below options
System.out.println("1. To new member registration.");
System.out.println("2. Display list of beneficiaries in the city.");
System.out.println("3. Display beneficiaries family size.");
System.out.println("4. Display number of beneficiaries that earn less than 100 per day.");
System.out.println("5. Quit.");
input = choice.nextLine();
// by this we are displaying studdent information
if(input.equals("1")){
while(true){
String flag = "true";
String ssn="";
System.out.println("Please enter the required details to register member ?");
System.out.println("Are you head of the family? Enter (y/n) \n");
String headMem = choice.nextLine();
System.out.println("Enter your income ?\n");
int income = choice.nextInt();
System.out.println("Please enter Social Security Number (SSN) ?\n");
ssn = choice.nextLine();
// check if he is head of the family and his income is less then 550
if(headMem.equalsIgnoreCase("n") || income > 550){
System.out.println("SORRY! You are not eligible for the SAP registration...");
flag = "false";
break;
}
// check if array list contain atleast one member to check ssn
if(memList.size()>0){
for(FamilyMember fm : memList){
if(fm.getSsn().equalsIgnoreCase(ssn)){
System.out.println("This "+ssn+" number is already exist\n");
System.out.println("CONGRATULATIONS! You are already registered for the SAP....THANK YOU!\n");
flag = "false";
break;
}
}
}
if(flag.equals("false")){
System.out.print("Do you want register another member? press (y/n)? ");
input = choice.nextLine();
if(input.equalsIgnoreCase("n")){
break;
}
}// falg if block
System.out.println("Please enter you full name: \n");
String name = choice.nextLine();
System.out.println("Please enter you city: \n");
String city = choice.nextLine();
System.out.println("Please enter you DOB in format (DD/MM/YYYY): \n");
String dob = choice.nextLine();
System.out.println("Please enter total members in your family: \n");
int familySize = choice.nextInt();
memList.add(new FamilyMember(ssn, name, dob, city, income , familySize));
System.out.println("CONGTRATULATIONS! Your registration completed succesfully.....\n");
System.out.println("Your registration details are below: \n");
System.out.println(" SSN: Name: DOB: City: Income: Family Size: Family Head ");
System.out.println(ssn+" "+ name+ " "+" "+ dob+" "+city+" "+income+" "+familySize+" "+headMem+"\n");
System.out.print("Do you want register another member? press (y/n)? ");
input = choice.nextLine();
if(input.equalsIgnoreCase("n")){
break;
}
} //end of if
}// inner while loop
// 2. Display list of beneficiaries in the city
else if(input.equals("2")){
// you can implement this method
}// else if end
//3. Display beneficiaries family size
else if(input.equals("3")){
// you can implement this method
}
// 4. Display number of beneficiaries that earn less than 100 per day.
else if(input.equals("4")){
int counter = 0;
for(FamilyMember fm: memList){
if(fm.getIncome()<100){
counter++;
}
}
System.out.println("Total number of beneficiaries that earn less than 100 per day are: "+counter);
}
else{
System.out.println("Quit from the system.");
break;
}
} // outer while loop
///// end while loop///////////////
}
}
Output: