A non-governmental organization needs a program to calculate the amount of finan
ID: 3732156 • Letter: A
Question
A non-governmental organization needs a program to calculate the amount of financial assistance for needy families. The formula is as follows:
Please Give me the Code to the Question in java for with methods as the way it is coded
•
•
•
Implement a method for this computation. Write a program that asks for the household income and number of children for each applicant, printing the amount returned by your method. Use –1 as a sentinel value for the input.
•
If the annual household income is between $30,000 and $40,000 and the household has at least three children, the amount is $1,000 per child.•
If the annual household income is between $20,000 and $30,000 and the household has at least two children, the amount is $1,500 per child.•
If the annual household income is less than $20,000, the amount is $2,000 per child.Explanation / Answer
FinancialAssistance.java
import java.util.Scanner;
public class FinancialAssistance {
public static void main(String[] args) {
//Declaring variables
double householdIncome,financialAssis;
int noOfChildren;
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
//Getting the input entered by the user
System.out.print("Enter the Household Income :$");
householdIncome=sc.nextDouble();
/* This while loop continues to execute
* until the user enters -1 as input
*/
while(householdIncome!=-1)
{
System.out.print("Enter no of childern :");
noOfChildren=sc.nextInt();
//calling the method
financialAssis=calFinancialAssistance(householdIncome,noOfChildren);
//Displaying the output
System.out.println("Financial Assistance Needed :$"+financialAssis);
//Getting the input entered by the user
System.out.print(" Enter the Household Income :$");
householdIncome=sc.nextDouble();
}
}
//This method will calculate the financial assistance
private static double calFinancialAssistance(double householdIncome,
int noOfChildren) {
double finacialAssis=0.0;
if(householdIncome>=30000 && householdIncome<=40000 && noOfChildren>=3)
{
finacialAssis=noOfChildren*1000;
}
else if(householdIncome>=20000 && householdIncome<=30000 && noOfChildren>=2)
{
finacialAssis=noOfChildren*1500;
}
else if(householdIncome<20000)
{
finacialAssis=noOfChildren*2000;
}
return finacialAssis;
}
}
_____________________
Output:
Enter the Household Income :$35000
Enter no of childern :4
Financial Assistance Needed :$4000.0
Enter the Household Income :$25000
Enter no of childern :2
Financial Assistance Needed :$3000.0
Enter the Household Income :$15000
Enter no of childern :2
Financial Assistance Needed :$4000.0
Enter the Household Income :$-1
________________Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.