Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Text file into an array then print

  • 07-05-2011 04:32PM
    #1
    Registered Users, Registered Users 2 Posts: 108 ✭✭


    Hi, I am new to Java.I am looking for some code for my mock exam.I am using netbeans and need to code to do the following.

    1.Provide the code to declare and create a two-dimensional String array to store data from answers.txt. Also, develop the actionPerformed method for the load button. When the user presses the load button the information should be read from answers.txt into this array.

    2.Develop the actionPerformed method for the display button. When the user presses the display button the students’ ids of those students who answered all questions correctly are displayed. The correct solution is TTFFTTFFTT. (Hint use JOptionPane to display).
    :)


Comments

  • Banned (with Prison Access) Posts: 1,332 ✭✭✭desaparecidos


    If you attended all of your classes / tutorials you would know how to do this.

    Never has there been an exam which asks you stuff that has not been covered.


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    We don't help with code unless we see some efforts that you have put in first.


  • Registered Users, Registered Users 2 Posts: 108 ✭✭HotP0pp3r


    2. Provide the code to declare and create a two-dimensional String array to store data from answers.txt. Also, develop the actionPerformed method for the load button. When the user presses the load button the information should be read from answers.txt into this array.
    (25 marks)
    this part is really confusing me , as i am unsure how to create an array that would link the answers.txt file to it and then load it ? :/

    This is my attempt where i am using a different approach in the load button which is this: , but i dont think its correct since there is no array the answers.txt is loading from :/

    try{
    file = new Scanner(new File("C:/Users/answers.txt"));
    while (file.hasNext()){
    count++;
    line = file.nextLine();

    System.out.println(+count+" "+line);
    }
    }catch (Exception e){
    System.out.println(e.getMessage());
    }finally{
    if (file != null)
    file.close();
    }


Advertisement