looking for help to sort into order - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

looking for help to sort into order

dramtiedramtie Posts: 1Member
im looking to sort my strings into alphbetical order but cant find the code to do it here is my initial coding





import java.io.*;
public class TutQ4
{
public static int getMark(int counter,String x) throws IOException
{
int n=0;
System.out.print("Please enter a mark for exam for "+x+" :");
n=DSInput.readInt();
return(n);
}

public static String getName(int counter) throws IOException
{
String x;
System.out.print("Please enter a name "+counter+":");
x=DSInput.readString();
return(x);
}

public static void printResults(String printName[],int printMark[]) throws IOException
{
for (int counter=0;counter<5;counter++)
{
System.out.println(printName[counter]+" scored "+printMark[counter]);
}
}

public static void pause() throws IOException
{
System.out.println("
Press any key to continue");
String dummy = DSInput.readString();
}


public static void main(String argv[]) throws IOException
{
int[] numbers;
numbers = new int[5];
String[] names;
names = new String[5];

for (int counter=0;counter<5;counter++)
{
names[counter] = getName(counter);
numbers[counter] = getMark(counter,names[counter]);

}


printResults(names,numbers);
pause();
}
}
Sign In or Register to comment.