parallel arrays

A menu-driven program in which I choose one one of these options and the program will carry out the request. The program will then display the same menu again and get another choice from the user.

1.List students names

2. List credits

3. Show total credits

4. List gpa's

5. Lits gpa's in ascending order

6. Show weighted avergae of gpa's

7. Show information about a given student

(can't graduate (gpa < 2.00)

(*** laude (3.45 <= gpa <3.65)

and so on...

8. Add a new student

9. Quit

Lets see where do I begin ughh!

throws java.io.*

publicclass StudentInfo

{

publicstaticvoid main (String [ ] args)

//declare variables

String names [ ] =new String [100];

String id# [ ] =new String [NUMELS];

int credits [ ] =newint [NUMELS];

double gpas [ ] =newdouble [NUMELS]

//sort the array

Which sort method should I use? Bubblesort?

I have been to tutoring every day this week and still can't get it down. It seems like everyone has their own java code. I need to use the code that they gave me in class. I really need an outline to follow. One person writes it in one way, another person writes the program out in a different way. I am close to withdrawing from this class. It's killing me! Sorry, needed to vent. Can anyone give me a outline that I can follow. I do not care if I have to memorize a million lines of code. I just need something to follow step by step. Thankyou guys!

[2108 byte] By [shivers20a] at [2007-10-2 12:34:58]
# 1

I don't know what kind of "routine" you're looking for, and memorizing a bunch of code is definitely NOT the way to learn to program.

First, why do you have parallel arrays? That's almost certainly a bad design decision, and it will make sorting very hard.

A better approach would be to define a Student class that captures name, id, credits, gpa.

Then, for sorting, you could write your own sort routine, which you might have to do if that's part of the assignment, or you could use what the Java API gives you.

If you write your own, bubblesort is just about the simplest, most intuitive sort, but it's also slow. If you have less than, oh, I don't know, maybe 1000 elements to sort, you probably won't notice any performance difference, so it's up to you.

If you want to use what Java gives you...

[url=http://www.onjava.com/lpt/a/3286]Making Java Objects Comparable[/url]

http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html

http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html

http://java.sun.com/docs/books/tutorial/collections/

jverda at 2007-7-13 9:35:06 > top of Java-index,Other Topics,Algorithms...