Raven Ryuuzaki
Raven Ryuuzaki

Reputation: 11

How can i see the previous records?

     public static BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
    public static int recno=0, recsize, choice, i=0, k=1;
    public static String ans;


     public static void main (String args[]) throws IOException
    {
        System.out.print("Enter Number of Records: ");
        recsize = Integer.parseInt(reader.readLine());
        String EmpNo[] = new String[recsize];
        String EmpName[] = new String[recsize];
        String Salary[] = new String[recsize];

        display_menu(EmpNo, EmpName, Salary,recno);
    }

How can i repeat this ? System.out.print("\nDo you want to see the next record ? [press p]"); For example i will put 3 records and want to see the other previous records until i reach in the first record.

        public static void pre_Rec(String EmpNo[], String EmpName[], String Salary[], int recno) throws IOException{

                String pre;
            System.out.print("\nEmployee Number: "+EmpNo[recno]);
            System.out.print("\nEmployee Number: "+EmpName[recno]);
            System.out.print("\nEmployee Number: "+Salary[recno]);
            System.out.print("\nDo you want to see the next record ? [press p]");
            pre = reader.readLine();


            if(pre!="p"){
                recno--;
                System.out.print("\nEmployee Number: "+EmpNo[recno]);
                System.out.print("\nEmployee Number: "+EmpName[recno]);
                System.out.print("\nEmployee Number: "+Salary[recno]);

                 }
                      System.out.println ("\n\nDo you want to go back in the Display Menu ? [y/n]: ");
                      ans = reader.readLine();
                      if (ans.equals("y")){
                      display_menu(EmpNo, EmpName, Salary,recno);
                    }
                      else{
                      System.out.println("Thank You for Using this Program!");
                    }


            }

Upvotes: 0

Views: 90

Answers (1)

lukescomputers
lukescomputers

Reputation: 57

Hello I would like to help you but your description is very vague and confusing could you please make a list describing the steps that this program is intended to do. I looked at your code and from I could gather from your description this may help.

    Scanner scanner = new Scanner(System.in);

    System.out.print("Enter Number of Records: ");
    int numOfRecords = scanner.nextInt();

    for(int x = 0; x <= numOfRecords; x++) {
    String EmpNo[] = new String[numOfRecords];
    String EmpName[] = new String[numOfRecords];
    String Salary[] = new String[numOfRecords];
   }

   //Whatever else you want to do

Upvotes: 1

Related Questions