這是假設返回19個全座位和68名學生剩餘價值! 請幫助,我的理解是我返回正確的值並將它們分配給正確的變量!方法返回零
public class JetCalculator
{
public static void main(String[] args)
{
int totalStudents = 3013;
int jetCapacity = 155;
int jets;
int students;
jets = calculateJets(jetCapacity, totalStudents);
students = calculateStudents(jetCapacity, totalStudents, jets);
System.out.println("A total of "+ totalStudents + " student require "+ jets + " full seated jets.");
System.out.println("There will be " + students + " students remaining");
System.out.println("_____________________________________________");
System.out.println(jets);
System.out.println(jetCapacity);
System.out.println(students);
}
public static int calculateJets(int totalStudents, int jetCapacity)
{
int fullJets;
fullJets = totalStudents/jetCapacity;
return fullJets;
}
public static int calculateStudents(int jetCapacity, int totalStudents, int jets)
{
int remainingStudents;
remainingStudents = jetCapacity * jets;
return remainingStudents;
}
}
那裏有多個方法 - 哪一個返回零,你期望它返回什麼? – 2012-03-06 00:05:53
如果這是家庭作業,它應該被標記爲這樣。如果您正確說明了問題,這將有所幫助。答案是19個全噴氣式飛機(所有座位都是噴氣式飛機),剩餘68名學生,而不是「19個全座位」。 – 2012-03-06 00:08:10