2014-03-04 78 views
-1

我新的编程和我的课我必须写以下的方法和程序:布尔和方法

boolean allTheSame(double x, double y, double z)返回的参数的平均值。

public static void main(String[] args) { 
    // **METHOD**// 

    Scanner in = new Scanner(System.in); 

    System.out.println("Enter variable for x"); 
    double x = in.nextDouble(); 

    System.out.println("Enter variable for y"); 
    double y = in.nextDouble(); 

    System.out.println("Enter variable for z"); 
    double z = in.nextDouble(); 

    boolean allTheSame = boolean allTheSame(x, y, z); 
    System.out.println(allTheSame); 

} 

    // **TEST PROGRAM** // 
public static boolean allTheSame(double x, double y, double z) 
{ 

    if (x == y && x == z) 
     { 
      return true; 
     } 

    else 
     { 
      return false; 
     } 


    } 

} 

鉴于我是新人,我该怎么做?

+0

你的具体问题是什么? – OSborn

+0

我知道,我对编程非常陌生,因为你可以说不太擅长 – FahrenheitNinetyNine

+0

你想知道什么吗? –

回答

1
boolean allTheSame = allTheSame(x, y, z); 
System.out.println(allTheSame); 

在调用方法之前,不需要放boolean

+0

谢谢!!!!!,现在我的程序正在工作 – FahrenheitNinetyNine

+0

@FahrenheitNinetyNine很好。在10分钟内(当它允许您接受答案时),请点击答案左侧的复选标记接受我的答案。 –