title: Loop and Array format
body: <p>I'm just finishing up this program I had to write for class. The program is supposed to get input from the user for the "ID" and "Day" and my teacher is asking us to put a loop in both those sections in case the user doesn't input the correct ID/Day. I've written the program to where it can take the input, but it won't be able to differentiate if the input is valid or not and will continue through the rest of the program. Also at the end of the array it's supposed to print the array and I've done that. I just would like to put the ID (A, B, C ,D) next to the array. I'd like for the end result to have the ID to the left of the array listed downwards to line up with the 4x5 table. If you guys have any advice/tips on how it could be done it'd be appreciated.</p>
  
  <pre><code>import java.util.Scanner;
  public class Salesman
  {
   public static void main(String[]args)
   {
    Scanner input = new Scanner(System.in);
    char[] names = {'A', 'B', 'C', 'D'};
    char[] days = {'M', 'T', 'W', 'H', 'F'};
    double[][] week = new double[4][5];
    int stop = 0;
    char nameInput;
    char dayInput;
    double cost;
    int row;
    int column;
  
    do
    {
          System.out.println("Enter the salesman ID as A, B, C or D.");
          String nameString = input.nextLine();
          nameInput = nameString.charAt(0);
          row = rowSearch(names, nameInput);
  
          System.out.println("Enter the day of the week as M, T, W, H, or F");
          String dayString = input.nextLine();
          dayInput = dayString.charAt(0);
          column = columnSearch(days, dayInput);
  
          System.out.println("Enter the amount of the sale");
          cost = input.nextDouble();
          week[row][column] = cost;
  
          System.out.println("Is there more data? Enter Y for more or N to stop");
          input.nextLine();
          String dataString = input.nextLine();
          char dataInput = dataString.charAt(0);
  
          if (dataInput == 'N')
          {
                  stop = -1;
          }
          else
          {
                  stop = 1;
          }
    }
    while (stop &gt;= 0);
  
    System.out.println("  M     T     W     H     F");
    for (row = 0; row &lt; week.length; row++)
    {
          for (column = 0; column &lt; week[row].length; column++)
          {
                  System.out.printf("$%1.2f ", week[row][column]);
          }
       System.out.println();
    }
   }
   public static int rowSearch(char[] names, char idInput)
   {
          int row = 0;
          for (int i = 0; i &lt; names.length; i++)
          {
                   if (idInput == names[i])
                    row = i;
          }
          return row;
   }
   public static int columnSearch(char[] days, char columnInput)
   {
          int column = 0;
          for (int i = 0; i &lt; days.length; i++)
          {
                  if (columnInput == days[i])
                    column = i;
          }
          return column;
   }
  }
  </code></pre>