Results 1 to 2 of 2
Thread: Project Question Urgent?
- 10-09-2009, 05:31 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 1
- Rep Power
- 0
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
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
kb.nextLine();
switch(choice) {
case 1://Add a student
addStudent(studentName, studentGrade, size);
size ++;
break;
case 2:// Update a student's grade
updateGrade (studentName, studentGrade, size);
break;
case 3: //Remove a student.
break;
case 4://View the gradebook.
viewBook (studentName, studentGrade, size);
break;
case 5://Display the highest grade.
HighGrade (studentName, studentGrade, size) ;
break;
case 6://Quit
out.println("Thanks for using the FriscoCorp system.");
}
}while(choice != 6);Last edited by newtocs; 10-09-2009 at 05:32 AM. Reason: cause i messed up
- 10-09-2009, 02:55 PM #2
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
-
Urgent! Need help for my final year project!!
By kazuma_riku73 in forum Sun Java Wireless ToolkitReplies: 7Last Post: 06-18-2010, 11:48 AM -
Urgent! Need help for my final year project!!
By kazuma_riku73 in forum Sun Java Wireless ToolkitReplies: 1Last Post: 01-15-2009, 11:14 AM -
A newbie question: How do I take a J2ME open source and create a project
By Anona in forum CLDC and MIDPReplies: 0Last Post: 09-28-2008, 11:02 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks