mardi 4 mars 2014

Financial Assistance Calculator


Vote count:

1




I am new to programming and I would appreciate the help on this problem: A program to calculate the amount of financial assistance. If the annual household income is between $30000 and $40000 and the household has at least three children, the amount is $1000 per child. If the annual household income is between $20000 and $30000 and the household has at least three children, the amount is $1500 per child. If the annual household income is less than $20000, the amount is $2000 per child. I have to implement a method and Use -1 as the sentinel value. Here is my program so far



public static void main(String[] args) {
// **METHOD** //
Scanner in = new Scanner(System.in);

System.out.println("What is the annual household income?");
double income = in.nextDouble();

System.out.println("How many children are in the household?");
int children = in.nextInt();

System.out.println("The financial assistance for this household is: "
+ assistance(income, children));
}
//**TEST PROGRAM**//
public static double assistance(double income, int children)
{
if(income >= 30000 && income < 40000 && children >= 3)
{
assistance = children * 1000; //says that it cannot find the symbol
}

else if(income >= 20000 && income < 30000 && children >= 2)
{
assistance = children * 1500;
}
else if(income < 20000)
{
assistance = children * 2000;
}
else
{
assistance = 0.0;
}

return assistance;
}
}


asked 3 mins ago






Aucun commentaire:

Enregistrer un commentaire