L'impôt sur le revenu calculatrice

package edu.westga.taxcalculator.model;

/**
 * Creates a taxReturn object
 */
public class TaxReturn {
    private double income;

    /**
     * Constructor for the TaxReturn class
     * 
     * @param income
     *            the income of the person.
     */
    public TaxReturn(double income) {
        if (income < 0) {
            throw new IllegalArgumentException(
                    "Income can't be less than zero.");
        }
        this.income = income;
    }

    public void getTax() {
        if (income <= 50000) {
            income *= 0.01;
        } else if (income <= 75000) {
            income *= 0.02;
        } else if (income <= 100000) {
            income *= 0.03;
        } else if (income <= 250000) {
            income *= 0.04;
        } else if (income <= 500000) {
            income *= 0.05;
        } else
            income *= 0.06;

    }
}

package edu.westga.taxcalculator.controller;

import java.util.Scanner;
import edu.westga.taxcalculator.model.TaxReturn;

public class TaxCalculatorController {
    public static void main(String[] args) {
        System.out.println("Please enter your income: ");
        Scanner theScanner = new Scanner(System.in);
        double income = theScanner.nextDouble();
        TaxReturn theCalculator = new TaxReturn(income);
        System.out.println("The amount of tax is: " + taxReturn.getTax());
    }
}

Je suis en train d'écrire un programme pour un impôt sur le revenu de la calculatrice et le projet a une classe et un testeur de classe. Il est à supposer pour calculer l'impôt sur le revenu du montant que j'ai entrer, mais il ne fonctionne pas si bien. Je vous serais reconnaissant de toute aide car je suis vraiment bloqué sur ce.

  • Comment est-il pas de travail? Qu'attendez-vous, et ce qui se passe à la place?
InformationsquelleAutor user3344737 | 2014-03-05