Reading from the File
<p>This program has 2 classes with a main method and is supposed to read from a file. My problem is that the line <code>double listPrice = fileScan.nextDouble();</code> gives an error exception like this <code>Exception in thread "main" java.util.InputMismatchException</code>. The error is in this class:</p>

<p>Here is contents of the file:<br>
Honda Accord</p>

<p>2004 16780.00 10.0</p>

<p>Chrysler SUV</p>

<p>2002 8600.00 0.0</p>

<p>Toyota Camry</p>

<p>2007 21799.99   3.0</p>

<p>Ford Escort</p>

<p>2006 12345.78   5.5</p>

<p>//note there is no space between each line </p>

<pre><code>class Proj1P2CarAryListService 
{

  private ArrayList&lt;Proj1CarData&gt; carList = new ArrayList&lt;Proj1CarData&gt;();

  public Proj1P2CarAryListService()
  {
     carList = new ArrayList&lt;Proj1CarData&gt;();
  }

  public void readStoreCarsData()
  {


     Scanner scan = new Scanner(System.in);

     Scanner fileScan;
     boolean validName = false;
     double discountAmount;
     double netPrice;

     do 
     {

        System.out.print("Enter file name: ");
        String str1 = scan.nextLine();

        try 
        {

           fileScan = new Scanner(new File(str1));
           validName = true;


           while (fileScan.hasNext())

           {

              String name = fileScan.nextLine();
              String modelYear = fileScan.next();
              double listPrice = fileScan.nextDouble();
              double percentDiscount = fileScan.nextDouble();

              discountAmount = listPrice * percentDiscount/100.0;
              netPrice = listPrice - discountAmount;

              Proj1CarData proj1 = new Proj1CarData(name, modelYear, listPrice, percentDiscount, discountAmount, netPrice);
              carList.add(proj1);
              System.out.println(proj1.toString());

           }// end while

        }// end try

           catch (FileNotFoundException fnfe)
           {
              System.out.println("Invalid File name; enter again");
           }

     } while (!validName);


  }//readStoreCarsData
</code></pre>
