Need help with input/output error
I am writing a program that needs me to input the assessed value of a home and then the output should be stored in a file. The program deals with property tax. I'm getting the error
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:840)
at java.util.Scanner.next(Scanner.java:1461)
at java.util.Scanner.nextDouble(Scanner.java:2387)
at Problem4.main(Problem4.java:33)
Here is my full code
Code Java:
// Stefan Springhetti
// Problem4
// 2/1/2001
import java.io.*;
import java.util.*;
import javax.swing.*;
public class Problem4 {
public static void main(String[] args)
throws FileNotFoundException
{
String inputStr;
double assessedValue;
double taxableAmount;
double taxRate;
double propertyTax;
taxableAmount = .92 * assessedValue;
taxRate = 1.05;
propertyTax = 1.05 * 92;
Scanner inFile =
new Scanner(new FileReader("tax.dat"));
PrintWriter outFile = new PrintWriter("output.dat");
inputStr = JOptionPane.showInputDialog
("Enter the assessed value");
assessedValue = Double.parseDouble(inputStr);
outFile.printf("Assesed Value: $" + String.format("%.2f", assessedValue) + "\n"
+ "Taxable Amount: $" + String.format("%.2f", taxableAmount)+ "\n"
+ "Tax Rate: $" + String.format("%.2f", taxRate) + "\n"
+ "Property Tax: $" + String.format("%.2f", propertyTax));
outFile.close();
}
}
Re: Need help with input/output error
I'm new to java, so sorry if this seems like a dumb question
Re: Need help with input/output error
I realize I dont need the inFile, but I cannot figure out the error. Help would be greatly appreciated
Re: Need help with input/output error
when i executed this program on my machine , its executing fine.
Re: Need help with input/output error
Well when I'm trying to run it on J Grasp I get the error message. I know the window pops up fine but after that is when I get the error message