The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

I Cant seem to get my sort routine to function

Well for a lab I have to calculate and output a receipt for a college tuition bill. The problem is the receipt has to be organized by name and when I run the program it only prints the first name in the correct position. Please help.

importjava.util.Scanner;publicclass Lab6_3
{//the constant of this program.staticfinaldouble RATE=173.36;//method for getting the tuition bill.staticdouble bill(int hours){return RATE*hours;}//method for printing out all of the information.staticvoid receipt(String name, int hours, int stud){double tuition=bill(hours);System.out.println();System.out.printf("%-15s",name);System.out.printf("%10s",hours);System.out.printf("%10s%-15.2f","$",tuition);System.out.println();}//start of main program.publicstaticvoid main(String[]args){
Scanner s=new Scanner(System.in);//declarations of the variables of the program.int stud, x, index, scan, min, temp2, length;String temp;//asking how many students at the college.System.out.print("How many students do you want to attend your college : ");
stud=s.nextInt();//declaring the arrays.int[]hours=newint[stud];String[]name=newString[stud];//for loop to ask for the student's name and hours.for(x=0;x<stud;x++){
s.nextLine();System.out.print("Enter student's name here : ");
name[x]=s.nextLine();System.out.print("Enter semester hours here : ");
hours[x]=s.nextInt();System.out.println();}//sort routine.for(index=0;index<name.length-1;index++){
min=index;for(scan=index+1;scan<name.length;scan++){if(name[scan].compareTo(name[min])<0);
min=scan;
temp=name[min];
name[min]=name[index];
name[index]=temp;
temp2=hours[min];
hours[min]=hours[index];
hours[index]=temp2;}
scan++;}//header for the output.System.out.println();System.out.print(" University of Derp");System.out.println();System.out.println();System.out.print("Student Hours Tuition");//for loop for outputting the receipt.for(x=0;x<name.length;x++)
receipt(name[x],hours[x],stud);System.out.println();}}