Results 1 to 3 of 3
- 02-06-2011, 09:34 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Need help with input/output program 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
// Stefan
// 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();
}
}Last edited by stefan2892; 02-06-2011 at 10:54 PM.
- 02-07-2011, 01:45 AM #2
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
bump, i realize I dont need the inFile, but i cannot figure out the error
- 02-07-2011, 07:57 PM #3
Similar Threads
-
File input output
By edcaru in forum New To JavaReplies: 5Last Post: 12-19-2010, 05:52 PM -
Two Class Program but No Output or Error
By H0AX in forum New To JavaReplies: 2Last Post: 12-09-2010, 06:27 AM -
help with data output, input
By collin389 in forum New To JavaReplies: 3Last Post: 11-11-2009, 05:34 PM -
Single XSD Creation for input/output
By lavanya82 in forum XMLReplies: 0Last Post: 03-13-2009, 12:02 PM -
how to record multiple input names and output later in program
By jbajwa1 in forum New To JavaReplies: 4Last Post: 10-02-2008, 10:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks