Java中的Math.pow错误 [英] Math.pow errors in Java

查看:101
本文介绍了Java中的Math.pow错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显然"只是在学习编程,并且似乎无法弄清楚该错误的解决方法.错误在第二行到最后一行-前一行:[System.out.print(+ windChill);]

I am 'obviously' just learning programming and I can't seem to figure out what to do in order to get rid if this error. The error is on the second to the last line - the line before: [System.out.print(+windChill);]

在这里(写在下面)是Java生成的可能提示"列表,用于说明我遇到的错误:

Here (written just below), are the list of Java-generated 'possible hints' for the errors that I am getting:


**')' 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...**

任何提示或澄清将不胜感激.请参见下面的代码.预先谢谢你.

Any hints or clarification would be most appreciated. Please see code below. Thank you in advance.

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 +温度-Math.pow(windSpeed * 16)+ Math.pow(温度* 16)))

Math.pow 需要两个参数.您只提供一个.

Math.pow requires two arguments. You are providing just one.

您是说 Math.pow(windSpeed,16)吗?

Math.pow被声明为公共静态双战俘(double a,double b)它将第一个参数的值返回第二个参数的幂.

Math.pow is declared as public static double pow(double a,double b) It returns the value of the first argument raised to the power of the second argument.

此外,左侧还有一个括号.

In addition you have an extra parenthesis at the left hand side.

这篇关于Java中的Math.pow错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆