* FAQ    * Search  * Register * Login 
Active topics
Unanswered topics

All times are UTC-06:00



Post new topic  Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Java Help Take 2
PostPosted: Fri Feb 24, 2006 4:19 pm 
Offline
DBB Ace
DBB Ace

Joined: Sun Nov 21, 1999 3:01 am
Posts: 176
ICQ: 61601718
Website: http://www.bakercountyonline.com
WLM: shade@redfaction.net
Yahoo Messenger: shaderfn
AOL: ShadeRF
Location: Florida
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:
Code:
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\");
      }
      }
   }
}

AND
Code:
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   
   }
}


Top
   
 Post subject:
PostPosted: Fri Feb 24, 2006 9:52 pm 
Offline
DBB Ace
DBB Ace
User avatar

Joined: Tue Jan 10, 2006 5:15 pm
Posts: 73
Website: http://www.viscerallogic.com
AOL: eMacPaul
Location: Ann Arbor, MI, USA
I didn't run it, so I don't know what every problem you're having is, but I did notice this:

Quote:
if(taxStatus = S && income < 10000)
taxAmount = income * taxRate1;
else
taxAmount = income * taxRate2;
if(taxStatus = M && income < 20000)


You need to have \"==\" instead of \"=\" in your if statements... right now you're assigning your taxStatus to S every time, then to M a little bit later.

_________________
Differentiation is an integral part of calculus.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Descent'rs have piloted these pages
 
The layout and contents contained within this site are © DescentBB.net 1997-2006.
Descent, Descent II are © Parallax Software Corporation.
Descent III is Outrage Entertainment.
Descent is a Trademark of Interplay Productions.

Miner Wars™ is trademark of Keen Software House s. r. o.
.


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group