我怎样才能把它打印在桌子上?我写它的方式我无法弄清楚如何在最后打印所有结果。这就是我所拥有的:
import java.util.Scanner;
public class FFLAverage{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Input the number of students");
int numofstu = input.nextInt();
double totalchange = 0;
for (int count = numofstu; count != 0; count--){
if (count == numofstu)
System.out.println("Last Name \t\t StartWeight \t\t End Weight \t\t Weight Change");
System.out.print("Enter student name: ");
String name = input.next();
System.out.print("Input start weight: ");
double start = input.nextDouble();
System.out.print("Enter end weight: ");
double end = input.nextDouble();
double change = (start - end);
totalchange += change;
System.out.println(name + "\t\t" + start + "\t\t\t" + end + "\t\t\t" + change);
}
double avg = totalchange / numofstu;
System.out.println("Average weight change: " + avg);
}
}
这就是输出的样子(控制台)
Last Name Start Weight End Weight Weight Change
Noble 222.5 202.4 -23.1
Tyler 189.5 194.4 +4.9
Pond 345.1 190.0 -155.1
Average weight change: --57.33