title: Scanner and arrayList
body: <p>I am stuck on a homework assignment that is my last project of the semester. I have to create a program with a Song class and a MP3_Player class. The problem I am having is taking the input from the user and putting it into an arrayList and also printing it out. Could someone help push me in the right direction. </p>
  
  <pre><code>package program3;
  
  import java.util.Scanner;
  
  
  
  
  
  /**
   *
   * @author Seth
   */
   public class Main {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      // TODO code application logic here
  
  
      Scanner sc = new Scanner(System.in);
  
      System.out.print("Enter the song's title:");
          String title = sc.nextLine();
      System.out.print("Enter the song's artist:");
          String artist = sc.nextLine();
      System.out.print("Enter the song's duration:");
          float duration = sc.nextFloat(); 
      System.out.print("Enter the size of the songs file: "); 
          int fileSize = sc.nextInt(); 
  
      Song song = new Song(title, artist, duration, fileSize);
          song.add(song);
  
      for (int i = 0; i&lt;song.length; i++){
          System.out.println("Song " + i + " title is: " + 
              song.getTitle() + ", the artist is " + 
              song.getArtist() + " and the duration is " + 
              String.valueOf(song.getDuration()) + ".");
      }
  
  }
  
  }
  
  
  
  
  
  
  package program3;
  
  import java.util.ArrayList;
  
  
  
   /**
   *
   * @author Seth
   */
  public class MP3_Player {
  
  private int freeSpace;
  private int storageCapacity;
  
  ArrayList&lt;Song&gt; songList = new ArrayList&lt;Song&gt;(); 
  
  
  
  public MP3_Player( )
  { 
     storageCapacity = 10;
     freeSpace = storageCapacity; 
  
  }
  
  public MP3_Player(int storage)
  {
      storageCapacity = storage; 
      freeSpace = storageCapacity;
  
  }    
  
  public String toString()
  {
      return "MP3 player with capacity " + storageCapacity + 
              ", " + freeSpace + " left, contains:\n" + 
      songList.toString().replace("[","").replace("]","").replace(",","\n");
  }
  
  public int getFreeSpace()
  {
      return freeSpace; 
  }
  
  public int getStorageCapacity()
  {
      return storageCapacity; 
  }
  
  public ArrayList&lt;Song&gt; getSongList()
  {
      return songList; 
  }
  
  public void setStorageCapacity(int newStorageCapacity)
  {
      storageCapacity = newStorageCapacity; 
  }
  
  public void setFreeSpace(int newFreeSpace)
  {
      if (newFreeSpace &gt;= 0) {
          freeSpace = newFreeSpace; 
      }
  }
  
  
  public void addSong(Song s)
  {
       if(s.getFileSize() &lt;= freeSpace)
       {
           songList.add(s);
           System.out.println(s.getTitle() + " added to the MP3 player."); 
           freeSpace -= s.getFileSize(); 
       }
       else
       {
           System.out.println("Cannot add " + s.getTitle() + 
                   " not enough free space.");
       }
  
  }
  
  
  public void removeSong(Song s)
  {
      boolean songRemoval = false; 
      for (Song i : songList)
      {
          if(s.equals(i))
          {
              freeSpace += s.getFileSize(); 
              songRemoval = true; 
              System.out.println(s.getTitle() + 
                      " is removed from the MP3 Player."); 
          }
          else if(s.equals(i))
          {
              System.out.println("This song isn't stored in the MP3 Player."); 
          }
      }
      if(songRemoval)
      {songList.remove(s); 
  }
  }
  }
  </code></pre>