Question
* This program calculates a tax refund amount based on the income for the year and the number of children a person has * The
* This program calculates a tax refund amount based on the income for the year and the number of children a person has
* The rules are:
*
* Income > 30000$ and <= 40000$ and ch >= 3, refund is 1000.0$ * ch
* Income > 20000$ and <= 30000$ and ch >= 2, refund is 1500.0$ * ch
* Income <= 20000$, refund is 2000.0$ * ch
*
* For example, if the income was 34312$ and the number of children (ch) was 7 then the tax refund would be: 1000*7 = 7000.0$
*
*/
import java.util.Scanner;
public class RefundAmount
{
public static void main(String[] args)
{
System.out.println("Refund: " + refund(23000.0,2) + " Expected: 3000.0") ;
System.out.println("Refund: " + refund(17500.0,4) + " Expected: 8000.0") ;
System.out.println("Refund: " + refund(80000.0,9) + " Expected: 0.0") ;
System.out.println("Refund: " + refund(35000.0,5) + " Expected: 5000.0") ;
System.out.println("Refund: " + refund(35000.0,-1) + " Expected: 0.0") ;
}
/**
Calculates the refund amount based on income and number of children.
@param income (double)
@param ch number of children (int)
@return refund amount (double)
return 0 unless:
Income > 30000$ and <= 40000$ and ch >= 3, refund is 1000.0$ * ch
Income > 20000$ and <= 30000$ and ch >= 2, refund is 1500.0$ * ch
Income <= 20000$, refund is 2000.0$ * ch
check to make sure ch > 0, return 0 if not
*/
//-----------Start below here. To do: approximate lines of code = 9
// write a static method called refund with the appropriate parameters and return type.
Step by Step Solution
3.47 Rating (157 Votes )
There are 3 Steps involved in it
Step: 1
static double refund double inc...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started