Click to See Complete Forum and Search --> : Help Compiling!!!


tootall2
10-09-2004, 04:05 PM
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);


}
}

Sportsdude11751
10-10-2004, 03:15 PM
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

Kram
10-10-2004, 09:36 PM
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?