Results 1 to 3 of 3
  1. #1
    stefan2892 is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default 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 11:54 PM.

  2. #2
    stefan2892 is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default

    bump, i realize I dont need the inFile, but i cannot figure out the error

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Perhaps you are attempting to read a number when the input is text?

Similar Threads

  1. File input output
    By edcaru in forum New To Java
    Replies: 5
    Last Post: 12-19-2010, 06:52 PM
  2. Two Class Program but No Output or Error
    By H0AX in forum New To Java
    Replies: 2
    Last Post: 12-09-2010, 07:27 AM
  3. help with data output, input
    By collin389 in forum New To Java
    Replies: 3
    Last Post: 11-11-2009, 06:34 PM
  4. Single XSD Creation for input/output
    By lavanya82 in forum XML
    Replies: 0
    Last Post: 03-13-2009, 01:02 PM
  5. Replies: 4
    Last Post: 10-02-2008, 11:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •