1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Income Tax Calculator Assignment

Discussion in 'Software Development' started by tombradysmistres, Dec 6, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. tombradysmistres

    tombradysmistres Thread Starter

    Joined:
    Nov 25, 2012
    Messages:
    7
    I am trying to write a program that calculates income tax based on income. I cannot get any output from it, nor does it ask for any input (income). I do not get any errors-build is successful, what am I doing wrong?




    import java.util.Scanner;

    public class IncomeTaxCalcualtor {



    public static void main(String[] args) {

    }

    public double computeIncomeTax() {

    Scanner in = new Scanner(System.in);
    double tax=0.0;
    double income;


    System.out.print("Please enter taxable income:");
    income = in.nextDouble();



    if (income < 50000) {
    if (income < 50000) {
    tax = tax + (income * .01);
    } else if (income>50000) {
    return tax + ((income - 50000) * .02);
    } else if (income>75000) {
    return tax + ((income - 75000) * .03);
    } else if (income>100000) {
    return tax + ((income - 75000) * .04);
    } else if (income>250000) {
    return tax + ((income - 100000) * .05);
    } else if (income>50000) {
    return tax + ((income - 500000) * .06);
    }



    System.out.print("Your tax liability is :" +tax);

    }
    return tax;
    }



    }
     
  2. TheShooter93

    TheShooter93 Malware Specialist

    Joined:
    Jul 9, 2008
    Messages:
    11,235
    First Name:
    Cody
    What happens when you import java.* instead of just scanner?
     
  3. tombradysmistres

    tombradysmistres Thread Starter

    Joined:
    Nov 25, 2012
    Messages:
    7
    I tried and got this : Import section does not correspond to the specified code style rules.
     
  4. TheShooter93

    TheShooter93 Malware Specialist

    Joined:
    Jul 9, 2008
    Messages:
    11,235
    First Name:
    Cody
    I played around with it in Eclipse for a while, but I have to go study for my stats test now.

    It has something to do with the fact that you're not calling anything in main.

    -----------------------------------

    I would just get rid of the process all being inside of a method and write in main. For a program like this, it's much simpler just to do that.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1079765

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice