2015-10-11 6 views
-1

Я пытаюсь выполнить программу incometax и продолжать получать 14 из этих ошибок. Пожалуйста, помогите.Класс, интерфейс или перечисление ожидаются 14 ошибок

/* 
*Printing IncomeTax 
*9/7/15 
*/ 


import java.util.Scanner; 

public class IncomeTax 
{ 
    public static void main(String[] args); 
    { 

    Scanner keyboard = new Scanner(System.in); 
    System.out.print("---Income Tax Program---\n\n\n"); 
    System.out.print("Your income:"); 
    double income = keyboard.nextDouble(); 
    System.out.print("Enter your filling status(S-Single,M-Married,J-JointlyFiling"); 
    char filing=keyboard.next().charAt(0); 

    System.out.print("Enter the number of deductions you are claiming:"); 
    int deductions = keyboard.nextInt(); 
    double taxableIncome = taxableIncome(income,deductions); 
    double taxPercent = taxPercent(filingStatus,taxIncome); 
    double owedAmount = taxableIncome*taxPercent; 
    double takeHome= income-owedAmount; 
    double taxPercent2=taxPercent*100; 
    System.out.print("Income tax Information: "); 
    System.out.printf("\nIncome- %.2f",income); 
    System.out.print("Filing status:"+filing); 
    System.out.printf("Taxable Income- %.2f",taxabeIncome); 
    System.out.printf("Tax percentage:"+taxPercent1+"%"); 
    System.out.printf("Tax owed: "+owedAmount); 
    System.out.printf("Take Home: "+takeHome); 

    } 
} 


public static double taxableIncome(double income,double deductions) 
    { 
    double taxIncome = income-5000-1000*deductions; 
    if (income>0) 
    return taxableIncome; 
    else 
    return 0; 

    } 
    public static double taxPercent(char filingStatus,double taxableIncome) 
    { 

    double taxPercent 
    if (taxIncome<=30000 && taxIncome>=0) 
    else if(filingStatus==S) 
      return==.05; 
    else if (filingStatus==M) 
     return==.08; 
    else (filing status==J) 
     return==.10; 
    } 

    { 
     if (taxIncome<L=50000 && taxIncome>30000) 
     else if (filingStatus == S) 
      return==.10; 
      else if(filingStatus == M) 
       return==.16; 
      else (filingStatus==J) 
       return==.20; 
    } 

    { 
      if (taxIncome>50000) 
      else if(filingStatus == S) 
        return==.20; 
       else if (filingStatus == M) 
        return ==.24; 
       else (filingStaus == J) 
        return==.30;  
    } 

--------------------Configuration: -------------------- C:\Users\Tazeen\Downloads\IncomeTax.java:41: error: class, interface, or enum expected public static double taxableIncome(double income,double deductions) ^C:\Users\Tazeen\Downloads\IncomeTax.java:44: error: class, interface, or enum expected if (income>0) ^ C:\Users\Tazeen\Downloads\IncomeTax.java:46: error: class, interface, or enum expected else ^ C:\Users\Tazeen\Downloads\IncomeTax.java:49: error: class, interface, or enum expected } ^ C:\Users\Tazeen\Downloads\IncomeTax.java:50: error: class, interface, or enum expected public static double taxPercent(char filingStatus,double taxableIncome) ^C:\Users\Tazeen\Downloads\IncomeTax.java:57: error: class, interface, or enum expected else if (filingStatus==M) ^C:\Users\Tazeen\Downloads\IncomeTax.java:59: error: class, interface, or enum expected else (filing status==J) ^C:\Users\Tazeen\Downloads\IncomeTax.java:61: error: class, interface, or enum expected } ^ C:\Users\Tazeen\Downloads\IncomeTax.java:67: error: class, interface, or enum expected else if(filingStatus == M) ^C:\Users\Tazeen\Downloads\IncomeTax.java:69: error: class, interface, or enum expected else (filingStatus==J) ^C:\Users\Tazeen\Downloads\IncomeTax.java:71: error: class, interface, or enum expected } ^C:\Users\Tazeen\Downloads\IncomeTax.java:77: error: class, interface, or enum expected else if (filingStatus == M) ^C:\Users\Tazeen\Downloads\IncomeTax.java:79: error: class, interface, or enum expected else (filingStaus == J) ^C:\Users\Tazeen\Downloads\IncomeTax.java:81: error: class, interface, or enum expected } ^14 errors

Процесс завершен.

ответ

0

Метод не в классе; переместите его внутри второй фигурной скобки.

К сожалению, этот код является полным беспорядком. Там все в порядке.

Вы, похоже, не заботитесь о том, чтобы уделять внимание тому, что вы делаете. Либо начните обращать внимание, либо отказаться от кодирования сегодня.

/* 
*Printing IncomeTax 
*9/7/15 
* @link https://stackoverflow.com/questions/33070915/class-interface-or-enum-expected-14-errors/33070940#3307094010 
*/ 


import java.util.Scanner; 

public class IncomeTax { 

    public static void main(String[] args) { 

     Scanner keyboard = new Scanner(System.in); 
     System.out.print("Your income:"); 
     double income = keyboard.nextDouble(); 
     System.out.print("Enter your filling status(S-Single,M-Married,J-JointlyFiling"); 
     char filingStatus = keyboard.next().charAt(0); 

     System.out.print("Enter the number of deductions you are claiming:"); 
     int deductions = keyboard.nextInt(); 
     double taxableIncome = getTaxableIncome(income, deductions); 
     double taxPercent = getTaxPercent(filingStatus, taxableIncome); 
     double owedAmount = taxableIncome * taxPercent; 
     double takeHome = income - owedAmount; 
     double taxPercent1 = taxPercent * 100; 
     System.out.println("Income tax Information: "); 
     System.out.println("Income: " + income); 
     System.out.println("Filing status: " + filingStatus); 
     System.out.println("Taxable Income: " + taxableIncome); 
     System.out.println("Tax percentage: " + taxPercent1); 
     System.out.println("Tax owed: " + owedAmount); 
     System.out.println("Take Home: " + takeHome); 
    } 

    public static double getTaxableIncome(double income, int numDeductions) { 
     double taxableIncome = income - 5000 - 1000 * numDeductions; 
     return (taxableIncome > 0.0 ? taxableIncome : 0.0); 
    } 

    public static double getTaxPercent(char filingStatus, double taxableIncome) { 
     double taxPercent = 0.0; 
     if (taxableIncome >= 0 && taxableIncome <= 30000) { 
      if (filingStatus == 'S') { 
       taxPercent = .05; 
      } else if (filingStatus == 'M') { 
       taxPercent = .08; 
      } else if (filingStatus == 'J') { 
       taxPercent = .10; 
      } else { 
       throw new IllegalArgumentException("Unknown tax percent"); 
      } 
     } else if (taxableIncome > 30000 && taxableIncome <= 50000) { 
      if (filingStatus == 'S') { 
       taxPercent = .10; 
      } else if (filingStatus == 'M') { 
       taxPercent = .16; 
      } else if (filingStatus == 'J') { 
       taxPercent = .20; 
      } 
     } else if (taxableIncome > 50000) { 
      if (filingStatus == 'S') { 
       taxPercent = .20; 
      } else if (filingStatus == 'M') { 
       taxPercent = .24; 
      } else if (filingStatus == 'J') { 
       taxPercent = .30; 
      } 
     } 
     return taxPercent; 
    } 
} 
Смежные вопросы