DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    3

    Help Compiling!!!

    i am writing a tax program and I have this error that I cant figure out.... java:19: incompatible types
    found : java.lang.String
    required: double
    double incomeValue = income;

    and

    java:20: incompatible types
    found : java.lang.String
    required: double
    double dependentsValue = dependents;

    Here is my source code:

    import java.io.*;
    import javax.swing.JOptionPane;
    public class StateTax
    {
    public static void main(String[] args) throws IOException
    {
    BufferedReader inData;
    inData = new BufferedReader(new InputStreamReader(System.in));

    //declaring Variables
    String income, dependents;
    double StateTaxDue;
    double incomeValue = income;
    double dependentsValue = dependents;

    //user input
    System.out.println("State Tax Computation");
    income = JOptionPane.showInputDialog(null, "Taxpayers Income:");
    dependents = JOptionPane.showInputDialog(null, "Number Of Dependents:");

    //Conversions
    StateTaxDue = 0.03 * incomeValue - (600 * dependentsValue);

    //output
    JOptionPane.showMessageDialog(null, "State Tax Due:" + StateTaxDue);
    System.exit(0);


    }
    }

  2. #2
    Join Date
    Jul 2004
    Posts
    83
    your saying a double = a string, or a letter = a number, and a letter doesn't equal a number, so your going to have to parse your String to a double
    They say if you play a Microsoft Windows CD backwards it will play satanic messages. But thats nothing, if you play it forwards it installs Windows.

  3. #3
    Join Date
    Sep 2004
    Posts
    223
    as sportsdude said, you cannot assign one itme to equal another item unless they are they same type, so remember that whenever a user enters data in from an input screen, it is allways stored as a String, so if you want to do any type of calculation on it then you must convert it to whatever type you want using the parsing mathods, do you know about them?
    A kram a day keeps the doctor......guessing

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links