我还没有在 main 上初始化任何东西。我想要的只是调用一个外部方法。但是,当调用 picnicCost() 时,我不知道在括号内放什么,因为我没有在 main.xml 中使用任何变量。
import java.util.*;
public class picnic
{
static Scanner scan=new Scanner(System.in);
public static void main(String args[])
{
picnicCost(0,0,0);
}
public static double flatFee(double a)
{
System.out.println("Enter the number of people attending: ");
a=scan.nextDouble();
return a*5.00;
}
public static double MealP(double b)
{
System.out.println("Enter the number of poeple purchasing a meal: ");
b=scan.nextDouble();
return b*2.75;
}
public static double iceCreamCost(double c)
{
System.out.println("Enter the number of poeple purchasing ice cream: ");
c=scan.nextDouble();
return c*.75;
}
public static double picnicCost(double a, double b, double c)
{
return flatFee(a) + MealP(b) + iceCreamCost(c);
}
}