2 Replies Latest reply on May 23, 2013 7:48 PM by dadams07

    Help with array/file lab

      Directions for lab: Your twin cousins, Ryan and Dana, have been collecting baseball cards for years. The cards are numbered sequentially from 1 to n. One day, while examining the cards, Ryan dropped them and one of the cards fell through a crack in the floor. Ryan would like to replace the lost card and has sent you a list of the n-1 cards he has recovered. Your job is to determine the lost card number before Dana realizes it’s missing.

      The first input line will contain the number of cases to process. This will be followed by one line per case that contains the number of baseball cards in the collection (which includes the lost card) followed by the card numbers of the cards that Ryan recovered. The numbers are separated by a space.

      There will be one line of output per case that gives the lost card number for that case.

      My Code:
      import java.io.*;
      import java.util.*;
      public class Stj1 {
            * @param args
           public static void main(String[] args) throws IOException {
                String input;
                int count=0, count2=0;
                int store=0, temp=0;
                String count1="1";
                FileReader fr = new FileReader("Twins.txt");
                BufferedReader br = new BufferedReader(fr);
                String [] elements =new String[100];
                String [] newelements = new String[100];
                     elements =input.split(" ");
                     int b = Integer.parseInt(elements[0],10);
                     String [] def = new String;
                     for(int i=1; i<elements.length; i++)
                     for(int k=0; k<def.length; k++)
                          int c = Integer.parseInt(count1,10);
                          count1= "" + c;
                     for(int i=0; i<def.length; i++)
                          for(int j=0; j<def.length-1; j++)
                               System.out.println(newelements[j] + def[i]);
                               store= temp;
      I keep getting errors....help please!
      Edited by: EJP on 20/05/2013 11:47: added {noformat}
      {noformat} tags: please use them.