title: stringindexoutofbounds with currency converter java program
body: <p>I am have trouble with a summary not showing up. I am supposed to modify a previous Java assignment by by adding an array of objects.  Within the loop, instantiate each individual object.   Make sure the user cannot keep adding another Foreign conversion beyond your array size.
      After the user selects quit from the menu, prompt if the user want to display a summary report.  If they select ‘Y’ then, using your array of objects, display the following report:  </p>
  
  <pre><code>Item     Conversion       Dollars     Amount  
   1       Japanese Yen     100.00    32,000.00   
   2       Mexican Peso     400.00    56,000.00  
   3       Canadian Dollar  100.00     156.00
  </code></pre>
  
  <p>etc.</p>
  
  <p>Number of Conversions = 3</p>
  
  <p>There are no errors when I compile..but when I run the program it is fine until I hit 0 to end the conversion and have it ask if i want to see a summary. This error displays:</p>
  
  <p>Exception in thread "main"
  java.lang.StringIndexOutOfBoundsException: String index out of range: 0
          at java.lang.String.charAt(String.java:658)
          at Lab8.main(Lab8.java:43)</p>
  
  <p>my code:</p>
  
  <blockquote>
  <pre><code>import java.util.Scanner;
  import java.text.DecimalFormat;
  
  public class Lab8
  {
      public static void main(String[] args)
      {
          final int Max = 10;
          String a;
          char summary;
          int c = 0;
        Foreign[] Exchange = new Foreign[Max];
        Scanner Keyboard = new Scanner(System.in);
  
        Foreign.opening();
  
          do
          {
           Exchange[c] = new Foreign();
             Exchange[c].getchoice();
           Exchange[c].dollars();
           Exchange[c].amount();
           Exchange[c].vertical();
           System.out.println("\n" + Exchange[c]);
           c++;
  
    System.out.println("\n" + "Please select 1 through 4, or 0 to quit" + &gt;"\n");
           c= Keyboard.nextInt();
  
          }
            while (c != 0);
  
  
          System.out.print("\nWould you like a summary of your conversions? (Y/N): ");
                a = Keyboard.nextLine();
                summary = a.charAt(0);
                summary = Character.toUpperCase(summary);
  
        if (summary == 'Y')
                {
        System.out.println("\nCountry\t\tRate\t\tDollars\t\tAmount");
                   System.out.println("========\t\t=======\t\t=======\t\t=========");
          for (int i=0; i &lt; Exchange.length; i++)
          System.out.println(Exchange[i]);
  
            Foreign.counter();
            }
      }
  }
  </code></pre>
  </blockquote>
  
  <p>I looked at line 43 and its this line: summary = a.charAt(0);</p>
  
  <p>But I am not sure what's wrong with it, can anyone point it out? Thank you.</p>