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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.