import java.util.Scanner; public class HW2Demo { /** * report bugs to xusun09@gmail.com * other solutions are ok */ public static void main(String[] args) { System.out.print("Please enter income: "); Scanner reader = new Scanner(System.in); double income = reader.nextDouble(); double tax=0; if (income>5700 && income<=(5700+8350)) { tax = (income-5700)*.1; } else if ((5700+8350)<income && income<=(5700+8350+33950)) { tax = 8350*.1+(income-5700-8350)*.15; } else if ((5700+8350+33950)<income && income<=(5700+8350+33950+82250)) { tax = 33950*.15+8350*.1+(income-5700-8350-33950)*.25; } else if ((5700+8350+33950+82250)<income && income<=(5700+8350+33950+82250+171550)) { tax = 82250*.25+33950*.15+8350*.1+ (income-5700-8350-33950-82250)*.28; } else if ((5700+8350+33950+82250+171550)<income && income<=(5700+8350+33950+82250+171550+372950)) { tax = 171550*.28+82250*.25+33950*.15+8350*.1+ (income-5700-8350-33950-82250-171550)*.33; } else if (income>372950) { tax = 171550*.33+171550*.28+82250*.25+33950*.15+8350*.1+ (income-5700-8350-33950-82250-171550-372950)*.35; } java.text.DecimalFormat df = new java.text.DecimalFormat("##.00"); tax = Double.parseDouble(df.format(tax)); System.out.println("Your taxes are $"+tax); } }
Monday, September 21, 2009
HW2 example
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment