title: Read multiple data types from txt file into arrayList - Java
body: <p>For this program I'm supposed to read from a txt file containing information on the automobile's <code>make</code>, <code>model</code>, <code>mpg</code>, and <code>trunk space</code> in that order. An example is:
       hyundai
       genesis
       24.6
       100
  and repeated for several different cars.
  We had to construct an "<code>Automobile</code>" superclass with the instance variables of make and model. Then a "<code>GasEngineAuto</code>" subclass with instance variable for mpg that extends "<code>Automobile</code>". Then a subclass called "<code>Sedan</code>" that extends "<code>GasEngine
  Auto</code>" and has instance variable for trunk space. For the assignment we had to get these classes signed off on to make sure that they made correctly. </p>
  
  <p>Write a method to read the information from the file <code>gas_sedans.txt</code> and store it in the list you created in the previous step. The list should be the only parameter for this method. Within the method, open the file, read the information for each sedan into appropriately-typed variables, call
  the parameterized constructor (the one that takes arguments for all attributes) to create the object, then add the object to the list. Call this method from main.</p>
  
  <p>Below is my code so far. I wanted to try to make sure I could read into the arrayList before I used a method to do it.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.ArrayList;
  import java.util.Scanner;
  
  /**
   *
   * @author 
   */
  public class lab10_prelab {
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) throws FileNotFoundException {
          
          ArrayList&lt;Sedan&gt; sedanList = new ArrayList&lt;Sedan&gt;();
  
          File myFile = new File(System.getProperty("user.dir")+"/src/gas_sedans (1).txt");
          if (!myFile.exists()){
              System.out.println("The file could not be found");
              System.exit(0);
          }
  
          Scanner inputFile = new Scanner(myFile);
          
          while (inputFile.hasNext())
          {
              Sedan a = new Sedan();
              a.setMake(inputFile.nextLine());
              a.setModel(inputFile.nextLine());
              inputFile.nextLine();
              a.setMPG(inputFile.nextDouble());
              inputFile.nextLine();
              a.setTrunkCapacity(inputFile.nextDouble());
              sedanList.add(a);
          }
          inputFile.close();
          }
          }</code></pre>
  </div>
  </div>
  </p>
  
  <p>It says that I get a InputMismatchException notice when I try to run the program.</p>