星期一, 10月 17, 2005

DISPLAY3.1+輸入數字

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class q1
{
public static void main(String[] args) throws IOException
{
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));

double netIncome, tax, fivePercentTax, tenPercentTax;

System.out.println("Enter net income.\n"
+ "Do not include a dollar sign or any commas.");
netIncome =Integer.parseInt(keyboard.readLine());


if (netIncome <= 15000)
tax = 0;
else if ((netIncome > 15000) && (netIncome <= 30000))
//tax = 5% of amount over $15,000
tax = (0.05*(netIncome - 15000));
else //netIncome > $30,000
{
//fivePercentTax = 5% of income from $15,000 to $30,000.
fivePercentTax = 0.05*15000;
//tenPercentTax = 10% of income over $30,000.
tenPercentTax = 0.10*(netIncome - 30000);
tax = (fivePercentTax + tenPercentTax);
}

System.out.print("Tax due = " +tax);
}
}

0 Comments:

張貼留言

<< Home