初学者Java-使用Eclipse需要帮助

初学者Java-使用Eclipse需要帮助,java,Java,为了完成这个Java项目,我已经绞尽脑汁好几天了,但在我的一生中,我无法让它运行。以下是我应该做的: 编写一个程序,从下面的列表中调用Math类的每个方法,并提供显示所调用的方法、发送到该方法的值以及返回结果的输出。列出的每个方法都会告诉您要使用哪些值。例如: 列出的方法:双电源双a、双b:使用2.0和3.0。您的程序将显示:Math.pow2.0,3.0=8.0。当调用接受双精度的方法时,使用至少有一个十进制数字的数字,如上面的示例所示,即使它是零。请记住,带小数的数字是双字面值。尝试使用能够

为了完成这个Java项目,我已经绞尽脑汁好几天了,但在我的一生中,我无法让它运行。以下是我应该做的:

编写一个程序,从下面的列表中调用Math类的每个方法,并提供显示所调用的方法、发送到该方法的值以及返回结果的输出。列出的每个方法都会告诉您要使用哪些值。例如:

列出的方法:双电源双a、双b:使用2.0和3.0。您的程序将显示:Math.pow2.0,3.0=8.0。当调用接受双精度的方法时,使用至少有一个十进制数字的数字,如上面的示例所示,即使它是零。请记住,带小数的数字是双字面值。尝试使用能够产生易于验证的结果的值

名单如下:

double pow(double a, double b): Use 3.0 and 2.0 double sqrt(double x): Use 25.0 int max(int a, int b): Use 6 and 2 double max(double a, double b): Use -50.0 and 7.0 static double random()
您的代码结构不正确。您有多种主要方法,这是一个大问题。特别是这个项目应该只有一个。您正在声明已存在的变量:

int variableA = 0;
int variableA; // Overrides old variableA thus resetting the value
相反,您应该这样做以使用变量:

int variableA = 0;
variableA = 10;
您还在main方法中声明无法执行的方法。这也是您出错的原因

public static double pow(double 3.0, double 2.0);
public static double sqrt(double 25);
public static int max(int 6, int 2);
public static double max(double -50, double 7)
public static double random()
在声明数据类型(如“double”)时,也不能写入“double 3.0”。接下来要写入的是变量名,而不是值。在继续之前,请复习Java和编程基础知识

在下面,您将发现您的代码已修复并重新格式化。然而,我不是为你做你的工作,所以你必须自己想办法完成它,并通过例子学习

在“Math.java”中:


我建议你读我建议你读课本的第二章和第三章。你没有真正走上正轨。你有没有给你的一个班级命名为数学?@TheJoeIaut不管这是不是真的,都没有必要粗鲁。你发布的错误与你问题中的代码无关。同样从你的代码来看,你似乎不知道静态意味着什么。也许在进一步研究之前,考虑一下阅读和阅读教程,我喜欢用java思考,但是从我头一回听到的:java也是好的。这很棒,我自己设法解决了这个问题。当我检查回来的时候,我发现了这个,所以我把它当作一个确认,我确实已经把它弄清楚了。谢谢你!同样,当您执行:public void randomstudio时,我需要将其更改为:public static void randomstudio,否则它将不会在main方法中执行randomstudio。
public class Method {

    public void main(String[] args) { 

public static double pow(double 3.0, double 2.0);
    public static double sqrt(double 25);
    public static int max(int 6, int 2);
    public static double max(double -50, double 7)
    public static double random()
    }
}

public class randomStudy{

   public void main(String[] args) {
       int min = 11;
               int max = -1;
               int total = 0;
    int i;
       for(i = 0; i < 1000; i++){
           int randomInt = (int)(11.0 * Math.random());
              System.out.println("Random integer between 1 and 10 : " + randomInt );
              int newtotal = (randomInt + int total);
              if int newtotal < int min {
                  int min = Math.random());
              }
              else{
                  System.out.println("int min");
              }
              if int newtotal > max {
                  int max = Math.random());
              }
              else{
                  System.out.println("int max");
              }
         }
       System.out.println("Min value:" + int min);
       System.out.println("Max Value:" + int max);
       System.out.println("Average:"+ int newtotal / 1000d);
   }
} 
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The method pow(double, double) is undefined for the type Math
    The method pow(double, double) is undefined for the type Math
    at Math.main(Math.java:3)
int variableA = 0;
int variableA; // Overrides old variableA thus resetting the value
int variableA = 0;
variableA = 10;
public static double pow(double 3.0, double 2.0);
public static double sqrt(double 25);
public static int max(int 6, int 2);
public static double max(double -50, double 7)
public static double random()
public class Math {
    public static void main(String[] args) {
        // Program starts here

        // Show and calculate math results here
        System.out.println("Math.pow(3.0, 2.0) = " + Math.pow(3.0, 2.0));
        // ...

        // This will execute the randomStudy method.
        randomStudy();
    }

    public void randomStudy() {
        // randomStudy method code goes here
        int min = 11;
        int max = -1;
        int total = 0;

        for(int i = 0; i < 1000; i++) {
            int randomInt = (int)(11.0 * Math.random());

            System.out.println("Random integer between 1 and 10: " + randomInt);

            int newtotal = (randomInt + total);

            if (newtotal < min) {
                min = Math.random());
            } else {
                System.out.println("Min: " + min);
            }

            if (newtotal > max) {
                max = Math.random());
            } else {
                System.out.println("Max: " + max);
            }
         }

         System.out.println("Min value:" + min);
         System.out.println("Max Value:" + max);
         System.out.println("Average:"+ newtotal / 1000d);
    }
}