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

Array Help!!

Options
  • 13-11-2008 5:34pm
    #1
    Registered Users Posts: 148 ✭✭


    Can anyone help with this program?

    Write a program to manage a 100-cell prison that allows the prison clerk to enter

    (i) the forename and surname of each prisoner
    (ii) age of each prisoner when he/she arrived in the prison
    (iii) original sentence handed down to the prisoner
    (iv) a seemingly random prison number allocated to each prisoner - this is entered by the prison clerk and may have meaning to him/her but not to the system. It's not anticipated that you use a random number generator. Rather the Prison Clerk will enter a number which he/she knows is used by no other prisoner. To the system, it will appear as a number chosen at random.


Comments

  • Registered Users Posts: 610 ✭✭✭nialo


    Create a class to store the prisoner information (forename, surname, age, sentence, id)
    Create an array to store a object. ie the prisoner class object.
    Put together a frontend to allow the data to be entered. probably a while loop that allows 100 objects to be entered into the array then finishes....


  • Registered Users Posts: 148 ✭✭spockpower


    Thanks fella:D

    im really struggling with my programming at the moment
    seem to have forget everything i learned last year:o


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    just a consideration, perhaps a database query upon each reload of the data input page to check if there's room in the "prison" would be more appropriate in terms of realism, if you implement a loop that allows 100 entries through the page then if you had to further develop this app to allow for prisoners leaving and you had say 67 prisoners, the loop would still allow 100 fresh entries...


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    spockpower wrote: »
    Can anyone help with this program?

    It helps a lot if you say what programming language. Also homework questions are frowned on unless you can show you have done some work on it.

    But what nailo said pretty much sums up what you need to do.


  • Registered Users Posts: 148 ✭✭spockpower


    Hobbes wrote: »
    It helps a lot if you say what programming language. Also homework questions are frowned on unless you can show you have done some work on it.

    But what nailo said pretty much sums up what you need to do.

    sorry its java and jsp pages.
    i have done some work on it but to be honest its pretty poor


  • Advertisement
  • Registered Users Posts: 148 ✭✭spockpower


    this is probably very wrong but the example he gave was similar to this

    class Prison
    {
    public static void main (String[]args)
    {

    String[]forename=new String[100];
    String[]firstname=new String[100];
    double[]idNo=new double[100];
    double[]age=new double[100];
    double[]orig_sentence=new double[100];

    int cellNo;
    int i;



    i=0;
    while (i<100)
    {
    System.out.println("Provide name and id No" + i);
    firstname=10;
    idNo=10;
    i++;
    }
    }
    }


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Please just note that at this time of year, every year, students come on here with questions like:
    Can anyone help with this program?

    Write a program to manage a 100-cell prison that allows the prison clerk to enter

    (i) the forename and surname of each prisoner
    (ii) age of each prisoner when he/she arrived in the prison
    (iii) original sentence handed down to the prisoner
    (iv) a seemingly random prison number allocated to each prisoner - this is entered by the prison clerk and may have meaning to him/her but not to the system. It's not anticipated that you use a random number generator. Rather the Prison Clerk will enter a number which he/she knows is used by no other prisoner. To the system, it will appear as a number chosen at random.


    Traditionaly I've banned these people, then I updated the forum charter, go read that before you post here again.


Advertisement