I am taking my first java course and am writing a program that calculates income tax. I am getting 3 identical errors that say "illegal start of expression" and point to the asterisks in the following code. I'm sure I'm making a rookie mistake but I'm not sure what to fix!
import java.util.Scanner;
public class Lab02
{
public static void main( String[] args )
{
Scanner input = new Scanner( System.in );
int exemptions; // Number of Exemptions
double grossSalary; // Gross Salary
double interestIncome; // Interest Income
double capitalGains; // Capital Gains
double charitableCont; // Charitable Contributions
double totalIncome; // Total Income
double adjustedIncome; // Adjusted Income
double totalTax; // Total Tax
System.out.print( "Number of Exemptions: ");
exemptions = input.nextInt();
System.out.print( "Gross Salary: ");
grossSalary = input.nextDouble();
System.out.print( "Interest Income: ");
interestIncome = input.nextDouble();
System.out.print( "Capital Gains: ");
capitalGains = input.nextDouble();
System.out.print( "Charitable Contributions: ");
charitableCont = input.nextDouble();
totalIncome = (grossSalary + interestIncome);
adjustedIncome = (totalIncome - (exemptions * 1500.00) - charitableCont);
if (adjustedIncome <= 10000)
totalTax0 = 0;
if (adjustedIncome > 10000)
totalTax1 = 15% * ( adjustedIncome >= 32000 ? (22000) : (adjustedIncome - 10000) );
if (adjustedIncome > 32000)
totalTax2 = 23% * (adjustedIncome >= 50000 ? (18000) : (adjustedIncome - 32000) );
if (adjustedIncome > 50000)
totalTax3 = 28% * (adjustedIncome - 50000);
totalTax = totalTax0 + totaltax1 + totaltax2 + totaltax3;
System.out.printf( "Total Income: $%.2f%n", totalIncome ); // display Total Income
System.out.printf( "Adjusted Income: $%.2f%n", adjustedIncome ); // display Adjusted Income
System.out.printf( "Total Tax: $%.2f%n", totalTax ); // display Total Tax
}
}
Aucun commentaire:
Enregistrer un commentaire