Axehack
In Runtime
- Messages
- 110
- Location
- http:\\www
This is the code I have:
I need to get the array do print grouped by Mark in descending order
Code:
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("\nPress 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();
}
}
I need to get the array do print grouped by Mark in descending order