I've debugged this program for an hour and a half now i figure its time to post here's my code
package chapter13;
import java.util.Scanner;
/**
* @author Austin Calkins
*/
public class Percentile {
static double highestPercent = 0;
static int highestScore = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] name = new String[100];
// Student a[] = new Student[100];
// System.out.println(a.getName());
double[][] marks = new double[100][2];
int numEntries = 0;
int numGreator = 0;
for (int loop = 0; loop < 100; loop++) {
System.out.println("name: ");
String temp = sc.next();
if (temp.equalsIgnoreCase("stop"))
break;
System.out.println("mark: ");
int tempMark = sc.nextInt();
numEntries++;
name[loop] = temp;
for (int i = 0; i < numEntries; i++) {
if (tempMark > marks[i][0]) {
for (int k = numEntries - 1; k < i; k--) {
marks[k][0] = marks[k - 1][0];
}
marks[i][0] = tempMark;
name[i] = temp;
break;
}
}
}// end for input
for (int loop = 0; loop < numEntries; loop++) {
for (int loop2 = 0; loop2 < numEntries; loop2++) {
if (marks[loop][0] >= marks[loop2][0]) {
numGreator++;
}
}
double percentile = ((double) numGreator / (double) numEntries) * 100.0;
marks[loop][1] = percentile;
numGreator = 0;
}
for (int loop = 0; loop < numEntries; loop++) {
System.out.println(name[loop] + ": percentile: " + marks[loop][1]);
}
}// end main
}// end class
i entered fred 72, mark 60, sally 90, austin 95, rick 95,
and the names were wrong and wo were the bottom three percentiles please help


LinkBack URL
About LinkBacks
Reply With Quote