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
}
}