Results 1 to 2 of 2
  1. #1
    newtocs is offline Member
    Join Date
    Oct 2009
    Rep Power

    Question Project Question Urgent?

    So I'm making this gradebook project and I'm so close to being finished but I'm stuck on how to remove a student from the array. I have to display a list of students and let the user select one (already done), i just don't know how i would take out that student. I know i need to change the length of the array and take the student out, I just don't know how. HELP!! thanks sorry gotta add the code

    public static void removeStudent(String []studentName, int [] studentGrade, int size){
    int choice;
    for (int i=0; i<size; i++){
    System.out.print (i +" "+studentName [i]+" "+studentGrade[i]);
    System.out.print ("Which student would you like to remove?");
    choice = kb.nextInt();

    ya it's in methods just assume everything else works heres the beginning
    int choice;
    int size = 0;
    String studentName[]= new String [25];
    int studentGrade[]= new int [25];

    out.println("Please enter your name");//Allows user to make choice
    String name = kb.nextLine();
    do {
    out.println("\n\n*******" + name + "'s Gradebook*******");
    out.println("1. Add a student");
    out.println("2. Update a student's grade");
    out.println("3. Remove a student");
    out.println("4. View the gradebook");
    out.println("5. Display the highest grade");
    out.println("6. Quit");
    out.print("\nPlease enter your selection: ");

    choice = kb.nextInt();

    //Clears the buffer

    switch(choice) {
    case 1://Add a student
    addStudent(studentName, studentGrade, size);
    size ++;

    case 2:// Update a student's grade
    updateGrade (studentName, studentGrade, size);


    case 3: //Remove a student.


    case 4://View the gradebook.
    viewBook (studentName, studentGrade, size);


    case 5://Display the highest grade.
    HighGrade (studentName, studentGrade, size) ;

    case 6://Quit
    out.println("Thanks for using the FriscoCorp system.");

    }while(choice != 6);
    Last edited by newtocs; 10-09-2009 at 06:32 AM. Reason: cause i messed up

  2. #2
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Houston, TX & Flint, MI
    Rep Power


    you can't change the length. Arrays have a fixed size ArrayLists are dynamic and can be changed on the fly. To remove a student from the list you can just set array[i] = null, where i = the students location.
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

Similar Threads

  1. Urgent! Need help for my final year project!!
    By kazuma_riku73 in forum Sun Java Wireless Toolkit
    Replies: 7
    Last Post: 06-18-2010, 12:48 PM
  2. Urgent! Need help for my final year project!!
    By kazuma_riku73 in forum Sun Java Wireless Toolkit
    Replies: 1
    Last Post: 01-15-2009, 12:14 PM
  3. Replies: 0
    Last Post: 09-28-2008, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts