-5
메인에서 아무 것도 초기화하지 않았습니다. 내가 원하는 건 외부 방법을 호출하는 것뿐입니다. 그러나 picnicCost()를 호출 할 때 main에서 변수를 사용하지 않았으므로 괄호 안에 무엇을 넣을 지 모르겠습니다.main에서 변수를 정의하지 않았더라도 main에서 메소드를 호출하는 방법.
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);
}
}
_ 변수를 사용하지 않았습니다. 그런 다음 수행하십시오. –
예를 들어 주 :'double flatFee = flatFee();'에 추가 할 수 있습니다. flatFee 메소드에서'a' 인수를 가질 필요가 없습니다. – assylias
처음 세 가지 방법 중 하나라도 매개 변수가 필요하지 않은 것처럼 보입니다. –