Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Sorting multiple arrays
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
scottyrush13




PostPosted: Thu May 18, 2006 9:03 am   Post subject: Sorting multiple arrays

I'm having trouble in a current java assignment and was wondering if anyone coul give me some direction, or jsut the next step so I can get this program done on my own.

We are to create methods to sort a student record by last name, overall grade average, and first name. The student record is in a .txt file, and i have already imported the information in the .txt file to different arrays in java. I have an array for first name, last name, and 8 different arrays because there are 8 different course each having a mark...i read the marks as a string, and then using parseInt made them integer, and i have calculated the average as a double...

i know how to sort the average and make it display from highest average to lowest, but how do i link it so that when it sorts the average and prints it from highest to lowest, it puts the corresponding name beside the average?

I have been trying hard on this assignment, and my knowledge of arrays is limited, if someone could give me a detailed explanation on what i need to do, i would love you forever.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu May 18, 2006 9:29 am   Post subject: (No subject)

Sounds like you're supposed to be creating a Student class, and sorting a single array of Student objects, rather than sorting multiple arrays.
scottyrush13




PostPosted: Thu May 18, 2006 9:37 am   Post subject: (No subject)

Java is really confusing and difficult for me, let me start by saying that.

Anyways, what I mean is that I have the student average in an array called 'average', but i also have OTHER arrays that store the students first name, last name, and the 8 individual course marks...

I need to make it sort the class by average and then print in table form, i need to know how to make it so that when i sort the list so it puts the highest average first, that the correct name goes beside it...instead of just the first name from the name array.

sorry i was really specific, but this assigment is giving me a major effing headache.
HellblazerX




PostPosted: Thu May 18, 2006 9:59 am   Post subject: (No subject)

Create a student class, that will hold the variables for the average, name, and the marks. Then make an array of instances of that class, and you can sort them based on their marks, and the name and other stuff will stay along with it.
wtd




PostPosted: Thu May 18, 2006 10:02 am   Post subject: (No subject)

An Introduction to Java

It's all there. How to create classes, how to create objects from those classes, and then how to sort them.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: