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.
import java.util.Scanner; public class Lab6_3 { //the constant of this program. static final double RATE=173.36; //method for getting the tuition bill. static double bill(int hours) { return RATE*hours; } //method for printing out all of the information. static void 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. public static void 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=new int[stud]; String[]name=new String[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(); } }