0
是否可以創建此子模塊?當所有代碼都在main中時,代碼工作正常,而不是作爲子模塊。創建子模塊FOR循環
{
public static void main (String [] arsg)
{
int number, inWeight, weight;
boolean veriWeight;
weight=inWeight();
System.out.println("Average month weight is "+(weight/12));
System.exit(0);
}
private static int inWeight();
{
for (int i=1; i<=12; i++)
{
number=ConsoleInput.readInt("enter month weight");
while (number<=0)
{
System.out.println("error, try again");
number=ConsoleInput.readInt("enter month weight");
}
inWeight += number;
}
return number;
}
}