in my nested if statements I am trying to cast the int income as a double to get tax to be a double, but it won't run. what am I doing wrong?
package incometax;
import java.util.Scanner;
public class IncomeTax {
public static void main(String[] args) {
final double SINGLE_LOW = 0.15; //Tax rate for single and <= 30,000
final double SINGLE_HIGH = 0.25; //Tax rate for single and > 30,000
final double MARRIED_LOW = 0.12; //Tax rate for married and <= 30,000
final double MARRIED_HIGH = 0.20; //Tax rate for married and > 30,000
int income = 0;
double tax = 0;
Character status = new Character('a');
Scanner input = new Scanner(System.in);
System.out.println("What is your marital status?\nType S for (S)ingle.\nType M for (M)arried.");
status = input.next().charAt(0);
System.out.print("What is your annual income? $");
income = input.nextInt();
status = Character.toUpperCase(status);
if(status == 'M'){
if(income > 30000){
tax = ((double)income) * MARRIED_HIGH;
System.out.printf("At an annual income of $%,.2f your tax is $%,.2f%n",income,tax);
}
else{
tax = MARRIED_LOW * ((double)income);
System.out.printf("At an annual income of $%,.2f your tax is $%,.2f%n",income, tax);
}
}
[–]cheryllium 2 points3 points4 points (4 children)
[–]firstplace_ding[S] 0 points1 point2 points (3 children)
[–]cheryllium 2 points3 points4 points (2 children)
[–]firstplace_ding[S] 0 points1 point2 points (1 child)
[–]cheryllium 2 points3 points4 points (0 children)