# Need Help. Reward: Pm'd RS account

## Recommended Posts

BTW.. this is very important to me, so please dont flame me on this thread calln me noob n shit.

Who ever helps me out with this i will give an rapidshare account that is secured till Thu, 23. Apr 2009

I need help bad. I got a test tommorrow on sorting objects in java and i forgot my notes at school and the notes our teacher has on his webpage is down. So i cant really studying. What i am asking is for all you pro hackers to help me. If some one completes the following two questions for me following the teachers request you will get the rs account. First person to do it gets it. But i need it within the next hour or so. At the latest 1 hour and 30 minutes.

here is the question

```Exercises in Sorting Objects
Assignment 1:

The Tallest in the Class

Each student in Mrs. Chapman’s class measured themselves using a metre stick and wrote down their height. The problem was that each student used a different unit of measurement, either metres(m), decimeteres(dm), centimetres(cm), or millimetres(mm). Your job is to find out the names of the tallest five people in the class.

The first line of the input file (tall.txt) will contain an integer n, 0<n<=35, representing the number of students in Mrs. Chapman’s class. The next n lines will contain the names, heights and unit of measurement of the students. Each item is separated by a single space. The heights will be a real value and the unit of measurement will be either m, dm, cm or mm.

The output to the console will contain five lines of data. It will list the names of the five tallest students in order. Use the insertion sort method.

If students have identical heights, their names should be listed in alphabetical order.

Sample Input

12
Jim 1.45 m
Sally 187 cm
Joey 1064 mm
Roel 15.23 dm
Karl 134 cm
Melanie 18.9 dm
Jill 1.54 m
Sam 133 cm
Joel 1877 mm
Roger 17.83 dm
Karen 178 cm
Marnie 17.9 dm

Sample Output

Melanie
Joel
Sally
Marnie
Roger
Assignment 2:

London Knights (Revisited)

The London Knights hockey team, last year’s Memorial Cup champions, has a roster of several players.

Many types of statistics are kept on the players, including games played (GP), goals (G), assists (A), points (PTS), plus/minus (+/-), penalty in minutes (PIM), power-play goals (PPG) and short-handed goals (SHG) .

# Lastname Firstname GP G A PTS +/- PIM PPG SHG

26 Aarssen Scott 38 2 8 10 14 8 0 0
10 Beaulieu Josh 31 10 8 18 11 77 4 1
14 Belan Kris 35 3 6 9 3 52 0 0
91 Bolland David 31 31 44 75 -1 50 2 2
15 Clarke Matt 38 4 4 8 3 14 0 0
4 Crawford Corbin 7 0 0 0 0 0 0 0
29 Davis Matt 6 1 0 1 0 19 0 0
28 Dennis Adam 34 0 2 2 0 22 0 0
The input file (knights.txt) will contain statistics for the players of the London Knights. The first line of the input file will contain N, the number of players in the input file. The next N lines will contain the statistics, as listed above, for each player. Each

statistic is separated from the other by a single space.

The output will be to the console. It will contain five lines of data. You will give the end user the choice of listing the top 5 of the following:

players with

1. Most Goals (G)
2. Most Assists (A)
3. Lowest Plus/Minus (+/-)
4. Most Penalty in Minutes (PIM)
5. Most Power Play Goals (PPG)

Sample Input

8
26 Aarssen Scott 38 2 8 10 14 8 0 0
10 Beaulieu Josh 31 10 8 18 11 77 4 1
14 Belan Kris 35 3 6 9 3 52 0 0
91 Bolland David 31 31 44 75 -1 50 2 2
15 Clarke Matt 38 4 4 8 3 14 0 0
4 Crawford Corbin 7 0 0 0 0 0 0 0
29 Davis Matt 6 1 0 1 0 19 0 0
28 Dennis Adam 34 0 2 2 0 22 0 0```

and heres his note specifcly for this

```Sorting Objects
Sorting Arrays of Objects:

With an array of objects, you can run comparisons of any field you want.
if (arCPlayer[b].PTS>arCPlayer[i].PTS)
//You can then switch full objects using a temporary object as follows:
tCPlayer=arCPlayer[iMin];
arCPlayer[iMin]=arCPlayer[i];
arCPlayer[i]=tCPlayer;

Here, you can see that we can compare the "PTS" within the array of players. Switching the two objects around requires a temporary object that I named "tCPlayer". Here, all fields within the object are being moved around.```

BTW if you dont have java or an ide. or the jdk heres a free bundle.

`http://java.sun.com/javase/downloads/netbeans.html`

##### Share on other sites

I don't know man. Java isn't my thing. Maybe you should google some java forums that could answer your question for you.

##### Share on other sites
I don't know man. Java isn't my thing. Maybe you should google some java forums that could answer your question for you.

thats actually a really good idea..thanks

SOLVED.

Question 1

```package ss11;
import java.util.*;
import java.io.*;
public class assignment1 {
public static void main(String[] args)throws IOException {
int nStudents;
nStudents = sin.nextInt();
Tall arCtall[] = new Tall[nStudents];
String sName, sUnit;
double dHeight;
for(int i=0;i<nStudents;i++){
arCtall[i] = new Tall();
sName = sin.next();
dHeight = sin.nextDouble();
sUnit = sin.next();
if(sUnit.equals("m")){
dHeight = dHeight*100;
}
else if(sUnit.equals("dm")){
dHeight = dHeight*10;
}
else if(sUnit.equals("mm")){
dHeight = dHeight/10;
}
arCtall[i].populate(sName, dHeight);
}
for (int i=0; i<nStudents-1; i++){
int iMin = i;
for(int j=i +1;j<nStudents; ++j){
if(arCtall[j].dHeight>arCtall[iMin].dHeight){
iMin = j;
}
if(iMin !=i){
double dTemp = arCtall[iMin].dHeight;
arCtall[iMin].dHeight=arCtall[i].dHeight;
arCtall[i].dHeight = dTemp;
String sTemp = arCtall[iMin].sName;
arCtall[iMin].sName=arCtall[i].sName;
arCtall[i].sName = sTemp;
}
iMin = i;
}
}
for (int i=0; i<nStudents-1; i++){
int iMin = i;
for(int j=i +1;j<nStudents; ++j){
if(arCtall[iMin].dHeight==arCtall[j].dHeight){
if(arCtall[j].sName.charAt(0)<arCtall[iMin].sName.charAt(0)){
iMin = j;
}
}
if(iMin !=i){
double dTemp = arCtall[iMin].dHeight;
arCtall[iMin].dHeight=arCtall[i].dHeight;
arCtall[i].dHeight = dTemp;
String sTemp = arCtall[iMin].sName;
arCtall[iMin].sName=arCtall[i].sName;
arCtall[i].sName = sTemp;
}
iMin = i;

}
}
for(int i = 0; i < 5; i++){
arCtall[i].Out();
}

}

}
class Tall{
String sName;
double dHeight;
public void populate(String _sName, double _dHeight){
sName = _sName;
dHeight = _dHeight;
}
public void Out(){
System.out.println(sName);
}
}```

Question 2

```package ss11;
import java.util.*;
import java.io.*;
public class assignment2 {
public static void main(String[] args)throws IOException {
String sNum, sLast, sFirst, sPlayer="";
int N = sin.nextInt(), nNum, nGP, nG, nA, nPTS, nPLUSMINUS, nPIM, nPPG, nSHG;
Players arCplayers[] = new Players[N];
for(int i=0;i<N;i++){
arCplayers[i] = new Players();
sNum = sin.next();
sLast = sin.next();
sFirst = sin.next();
sPlayer = sNum+" "+sLast+" "+sFirst;
nGP = sin.nextInt();
nG = sin.nextInt();
nA = sin.nextInt();
nPTS = sin.nextInt();
nPLUSMINUS = sin.nextInt();
nPIM = sin.nextInt();
nPPG = sin.nextInt();
nSHG = sin.nextInt();
arCplayers[i].populate(sPlayer, nGP, nG, nA, nPTS, nPLUSMINUS, nPIM, nPPG, nSHG);
}
do{
int nChoice;
Scanner sin2 = new Scanner(System.in);
System.out.print("1. Most Goals (G), 2. Most Assists (A), 3. Lowest Plus/Minus (+/-), 4. Most Penalty in Minutes (PIM), 5. Most Power Play Goals (PPG): ");
nChoice = sin2.nextInt();
if(nChoice == 0)break;
else if(nChoice == 1){
for (int i=0; i<N-1; i++){
int iMin = i;
for(int j=i +1;j<N; ++j){
if(arCplayers[j].nG>arCplayers[iMin].nG){
iMin = j;
}
if(iMin !=i){
String sTemp = arCplayers[iMin].sPlayer;
arCplayers[iMin].sPlayer=arCplayers[i].sPlayer;
arCplayers[i].sPlayer = sTemp;
int nTemp = arCplayers[iMin].nGP;
arCplayers[iMin].nGP=arCplayers[i].nGP;
arCplayers[i].nGP = nTemp;
int nTemp2 = arCplayers[iMin].nG;
arCplayers[iMin].nG=arCplayers[i].nG;
arCplayers[i].nG = nTemp2;
int nTemp3 = arCplayers[iMin].nA;
arCplayers[iMin].nA=arCplayers[i].nA;
arCplayers[i].nA = nTemp3;
int nTemp4 = arCplayers[iMin].nPTS;
arCplayers[iMin].nPTS=arCplayers[i].nPTS;
arCplayers[i].nPTS = nTemp4;
int nTemp5 = arCplayers[iMin].nPLUSMINUS;
arCplayers[iMin].nPLUSMINUS=arCplayers[i].nPLUSMINUS;
arCplayers[i].nPLUSMINUS = nTemp5;
int nTemp6 = arCplayers[iMin].nPIM;
arCplayers[iMin].nPIM=arCplayers[i].nPIM;
arCplayers[i].nPIM = nTemp6;
int nTemp7 = arCplayers[iMin].nPPG;
arCplayers[iMin].nPPG=arCplayers[i].nPPG;
arCplayers[i].nPPG = nTemp7;
int nTemp8 = arCplayers[iMin].nSHG;
arCplayers[iMin].nSHG=arCplayers[i].nSHG;
arCplayers[i].nSHG = nTemp8;
}
iMin = i;
}
}
}
else if(nChoice == 2){
for (int i=0; i<N-1; i++){
int iMin = i;
for(int j=i +1;j<N; ++j){
if(arCplayers[j].nA>arCplayers[iMin].nA){
iMin = j;
}
if(iMin !=i){
String sTemp = arCplayers[iMin].sPlayer;
arCplayers[iMin].sPlayer=arCplayers[i].sPlayer;
arCplayers[i].sPlayer = sTemp;
int nTemp = arCplayers[iMin].nGP;
arCplayers[iMin].nGP=arCplayers[i].nGP;
arCplayers[i].nGP = nTemp;
int nTemp2 = arCplayers[iMin].nG;
arCplayers[iMin].nG=arCplayers[i].nG;
arCplayers[i].nG = nTemp2;
int nTemp3 = arCplayers[iMin].nA;
arCplayers[iMin].nA=arCplayers[i].nA;
arCplayers[i].nA = nTemp3;
int nTemp4 = arCplayers[iMin].nPTS;
arCplayers[iMin].nPTS=arCplayers[i].nPTS;
arCplayers[i].nPTS = nTemp4;
int nTemp5 = arCplayers[iMin].nPLUSMINUS;
arCplayers[iMin].nPLUSMINUS=arCplayers[i].nPLUSMINUS;
arCplayers[i].nPLUSMINUS = nTemp5;
int nTemp6 = arCplayers[iMin].nPIM;
arCplayers[iMin].nPIM=arCplayers[i].nPIM;
arCplayers[i].nPIM = nTemp6;
int nTemp7 = arCplayers[iMin].nPPG;
arCplayers[iMin].nPPG=arCplayers[i].nPPG;
arCplayers[i].nPPG = nTemp7;
int nTemp8 = arCplayers[iMin].nSHG;
arCplayers[iMin].nSHG=arCplayers[i].nSHG;
arCplayers[i].nSHG = nTemp8;
}
iMin = i;
}
}
}
else if(nChoice == 3){
for (int i=0; i<N-1; i++){
int iMin = i;
for(int j=i +1;j<N; ++j){
if(arCplayers[j].nPLUSMINUS<arCplayers[iMin].nPLUSMINUS){
iMin = j;
}
if(iMin !=i){
String sTemp = arCplayers[iMin].sPlayer;
arCplayers[iMin].sPlayer=arCplayers[i].sPlayer;
arCplayers[i].sPlayer = sTemp;
int nTemp = arCplayers[iMin].nGP;
arCplayers[iMin].nGP=arCplayers[i].nGP;
arCplayers[i].nGP = nTemp;
int nTemp2 = arCplayers[iMin].nG;
arCplayers[iMin].nG=arCplayers[i].nG;
arCplayers[i].nG = nTemp2;
int nTemp3 = arCplayers[iMin].nA;
arCplayers[iMin].nA=arCplayers[i].nA;
arCplayers[i].nA = nTemp3;
int nTemp4 = arCplayers[iMin].nPTS;
arCplayers[iMin].nPTS=arCplayers[i].nPTS;
arCplayers[i].nPTS = nTemp4;
int nTemp5 = arCplayers[iMin].nPLUSMINUS;
arCplayers[iMin].nPLUSMINUS=arCplayers[i].nPLUSMINUS;
arCplayers[i].nPLUSMINUS = nTemp5;
int nTemp6 = arCplayers[iMin].nPIM;
arCplayers[iMin].nPIM=arCplayers[i].nPIM;
arCplayers[i].nPIM = nTemp6;
int nTemp7 = arCplayers[iMin].nPPG;
arCplayers[iMin].nPPG=arCplayers[i].nPPG;
arCplayers[i].nPPG = nTemp7;
int nTemp8 = arCplayers[iMin].nSHG;
arCplayers[iMin].nSHG=arCplayers[i].nSHG;
arCplayers[i].nSHG = nTemp8;
}
iMin = i;
}
}
}
else if(nChoice == 4){
for (int i=0; i<N-1; i++){
int iMin = i;
for(int j=i +1;j<N; ++j){
if(arCplayers[j].nPIM>arCplayers[iMin].nPIM){
iMin = j;
}
if(iMin !=i){
String sTemp = arCplayers[iMin].sPlayer;
arCplayers[iMin].sPlayer=arCplayers[i].sPlayer;
arCplayers[i].sPlayer = sTemp;
int nTemp = arCplayers[iMin].nGP;
arCplayers[iMin].nGP=arCplayers[i].nGP;
arCplayers[i].nGP = nTemp;
int nTemp2 = arCplayers[iMin].nG;
arCplayers[iMin].nG=arCplayers[i].nG;
arCplayers[i].nG = nTemp2;
int nTemp3 = arCplayers[iMin].nA;
arCplayers[iMin].nA=arCplayers[i].nA;
arCplayers[i].nA = nTemp3;
int nTemp4 = arCplayers[iMin].nPTS;
arCplayers[iMin].nPTS=arCplayers[i].nPTS;
arCplayers[i].nPTS = nTemp4;
int nTemp5 = arCplayers[iMin].nPLUSMINUS;
arCplayers[iMin].nPLUSMINUS=arCplayers[i].nPLUSMINUS;
arCplayers[i].nPLUSMINUS = nTemp5;
int nTemp6 = arCplayers[iMin].nPIM;
arCplayers[iMin].nPIM=arCplayers[i].nPIM;
arCplayers[i].nPIM = nTemp6;
int nTemp7 = arCplayers[iMin].nPPG;
arCplayers[iMin].nPPG=arCplayers[i].nPPG;
arCplayers[i].nPPG = nTemp7;
int nTemp8 = arCplayers[iMin].nSHG;
arCplayers[iMin].nSHG=arCplayers[i].nSHG;
arCplayers[i].nSHG = nTemp8;
}
iMin = i;
}
}
}
else if(nChoice == 5){
for (int i=0; i<N-1; i++){
int iMin = i;
for(int j=i +1;j<N; ++j){
if(arCplayers[j].nPPG>arCplayers[iMin].nPPG){
iMin = j;
}
if(iMin !=i){
String sTemp = arCplayers[iMin].sPlayer;
arCplayers[iMin].sPlayer=arCplayers[i].sPlayer;
arCplayers[i].sPlayer = sTemp;
int nTemp = arCplayers[iMin].nGP;
arCplayers[iMin].nGP=arCplayers[i].nGP;
arCplayers[i].nGP = nTemp;
int nTemp2 = arCplayers[iMin].nG;
arCplayers[iMin].nG=arCplayers[i].nG;
arCplayers[i].nG = nTemp2;
int nTemp3 = arCplayers[iMin].nA;
arCplayers[iMin].nA=arCplayers[i].nA;
arCplayers[i].nA = nTemp3;
int nTemp4 = arCplayers[iMin].nPTS;
arCplayers[iMin].nPTS=arCplayers[i].nPTS;
arCplayers[i].nPTS = nTemp4;
int nTemp5 = arCplayers[iMin].nPLUSMINUS;
arCplayers[iMin].nPLUSMINUS=arCplayers[i].nPLUSMINUS;
arCplayers[i].nPLUSMINUS = nTemp5;
int nTemp6 = arCplayers[iMin].nPIM;
arCplayers[iMin].nPIM=arCplayers[i].nPIM;
arCplayers[i].nPIM = nTemp6;
int nTemp7 = arCplayers[iMin].nPPG;
arCplayers[iMin].nPPG=arCplayers[i].nPPG;
arCplayers[i].nPPG = nTemp7;
int nTemp8 = arCplayers[iMin].nSHG;
arCplayers[iMin].nSHG=arCplayers[i].nSHG;
arCplayers[i].nSHG = nTemp8;
}
iMin = i;
}
}
}
for(int i = 0; i < 5; i++){
arCplayers[i].Out();
}
}while(true);
}
}
class Players{
String sPlayer;
int nGP, nG, nA, nPTS, nPLUSMINUS, nPIM, nPPG, nSHG;
public void populate(String _sPlayer, int _nGP, int _nG, int _nA, int _nPTS, int _nPLUSMINUS, int _nPIM, int _nPPG, int _nSHG){
sPlayer = _sPlayer;
nGP = _nGP;
nG = _nG;
nA = _nA;
nPTS = _nPTS;
nPLUSMINUS = _nPLUSMINUS;
nPIM = _nPIM;
nPPG = _nPPG;
nSHG = _nSHG;
}
public void Out(){
System.out.println(sPlayer+" "+nGP+" "+nG+" "+nA+" "+nPTS+" "+nPLUSMINUS+" "+nPIM+" "+nPPG+" "+nSHG);
}
}```

##### Share on other sites

So how is this Serious Discussion again? Someone tell me or move this thread to its appropriate place. Sheesh.