我“显然”只是在学习编程,我似乎不知道该怎么做才能摆脱这个错误。错误位于倒数第二行 - 之前的行: [System.out.print(+windChill);]
这里(写在下面)是 Java 生成的针对我遇到的错误的“可能提示”列表:
**')' expected
method pow in class java.lang.Math cannot be applied to given types
required: double,double
found: double
method pow in class java.lang.Math cannot be applied to given types
required: double,double
found: double
operator + cannot be applied to double,pow
incompatible types
required: doub...**
任何提示或澄清将不胜感激。请参阅下面的代码。先感谢您。
Shane
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO code application logic here
Scanner input = new Scanner(System.in);
System.out.print("Enter a temperature between -58 and 41 degrees Fahrenheit and press ENTER");
double temperature = input.nextDouble();
System.out.print("Enter a wind speed that is 2 miles per hour or faster and press ENTER");
double windSpeed = input.nextDouble();
double windChill = (((35.41 + temperature - Math.pow(windSpeed * 16) + Math.pow(temperature * 16)));
System.out.print(+windChill);
}
}
(((35.41 + temperature - Math.pow(windSpeed * 16) + Math.pow(temperature * 16)))
Math.pow需要两个参数。您只提供一个。
你的意思Math.pow(windSpeed,16)
?
Math.pow 声明为public static double pow(double a,double b)
它返回第一个参数的第二个参数次方的值。
此外,左侧还有一个额外的括号。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)