Java Help Take 2
Posted: Fri Feb 24, 2006 4:19 pm
I am writing another program and am having problems as usual. The program is suppose to find the tax status of the user and the income, then calculate the taxes. Once the information displays, it allows the user to choose if they wish to do this for another user. Please take a look at the following:
AND
Code: Select all
import javax.swing.JOptionPane;
public class Taxes
{
public static void main(String[] args)
{
int selection;
double taxRate1 = .15;
double taxRate2 = .30;
selection = JOptionPane.showConfirmDialog(null,
\"Do you want to continue tax caluculation for another person\");
while(selection == JOptionPane.YES_OPTION)
{
TaxReturn aTaxReturn = new TaxReturn(taxStatus, income);
aTaxReturn.taxStatus = JOptionPane.showInputDialog(null,
\"Please enter your tax payer type. I.E. S for Single, M for Married\");
taxStatus = aTaxReturn.taxStatus;
aTaxReturn.income = JOptionPane.showInputDialog(null,
\"Please enter your income.\");
income = Double.parseDouble(incomeString);
public void calculateTax()
{
if(taxStatus = S && income < 10000)
taxAmount = income * taxRate1;
else
taxAmount = income * taxRate2;
if(taxStatus = M && income < 20000)
taxAmount = income * taxRate1;
else
taxAmount = income * taxRate2;
JOptionPane.showMessageDialog(null,
\"The tax status is \" + taxStatus + \". The income is \" + income + \". The tax amount is \" + taxAmount);
selection = JOptionPane.showConfirmDialog(null,
\"Do you want to continue tax caluculation for another person\");
}
}
}
}
Code: Select all
public class TaxReturn
{
private double income;
private char taxStatus;
public double getIncome()
{
return income;
}
public char getStatus()
{
return taxStatus;
}
public void setIncome(userIncome)
{
income = userIncome
}
public void setStatus(userStatus)
{
taxStatus = userStatus
}
}