简体   繁体   English

Java的一些基本数学函数对初学者有问题。 我做错了什么吗?

[英]Having a beginner issue with some basic math functions in Java. Anything I'm doing wrong?

EDIT: Thanks a ton for everyone who has helped. 编辑:谢谢大家的帮助。 I can't believe I missed that single typo. 我简直不敢错过那个错别字。

I'm in need of help for some basic math in Java. 我需要Java基本数学方面的帮助。 I'm trying to create a heat index calculator but when Java compiles runs the program the calculator seems to slip up. 我正在尝试创建一个热量指数计算器,但是当Java编译运行该程序时,计算器似乎会丢失。 I've checked it over multiple times to see the problem but cant find anything. 我已经检查了多次,以查看问题,但找不到任何东西。 Help would be greatly appreciated. 帮助将不胜感激。

Code: 码:

    double t = 84.3; //temperature
    int h = 81;    //humidity
    //the following are parts of the heat index formula
    double c1 = -42.379;
    double c2 = 2.04901523;
    double c3 = 10.14333127;
    double c4 = -0.22475541;
    double c5 = -.00683783;
    double c6 = -5.481717E-2;
    double c7 = 1.22874E-3;
    double c8 = 8.5282E-4;
    double c9 = -1.99E-6;
    double hI = c1 + c2 * t + c3 * h + c4 * t * h + c5 * t*t + c6 * h*h + c7 * t*t * h + c8 * t + h*h + c9 * t*t * h*h; //formula for calculating heat index
    System.out.println(hI);

So the problem here is that instead of giving me the desired output (heat index), it's returning a very large number (6184.5981258548). 所以这里的问题是,它没有给我期望的输出(热指数),而是返回了非常大的数字(6184.5981258548)。 Is there an issue with my code? 我的代码有问题吗? Once again, any help would be appreciated. 再一次,任何帮助将不胜感激。 Thanks. 谢谢。

According to the Heat Index Wikipedia page , then c8 term should be: 根据Heat Index Wikipedia页面 ,则c8术语应为:

c 8 TR 2 c 8 TR 2

But you have for that term: 但是你有这个名词:

c8 * t + h*h 

Try 尝试

c8 * t * h*h 

Making this change, I get as output: 进行此更改,我得到以下输出:

95.21440841480018

您在c8*t + h*h有错字应该是c8*t*h*h

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我需要一些帮助来使用 java 开始这个离散数学。 我完全不知所措 - I need some helping starting this discrete math using java. I'm at a complete loss 我正在尝试使用Java更新oracle数据库中的密码。 难道我做错了什么? - I'm trying to update my password in oracle database using Java. Am I doing something wrong? 我在使用 MyBatis/java 似乎是一个简单的插入时遇到了问题。 - I'm having an issue with what would seem to be a simple insert using MyBatis/java. 我在使用Java使用输入和输出重定向时遇到麻烦。 有人可以告诉我哪里出了问题吗? - I'm having trouble using input and output redirection using Java. Could somebody tell me where in going wrong with it? Java 作业(初学者)- 我认为我的数学或声明有问题? - Java Homework (beginner) - I think there is something wrong with my math or declarations? 无法在java中读取char数组。 我究竟做错了什么? - Trouble reading a char array in java. What am I doing wrong? 我对ArrayList并不了解,我需要一些基本功能 - I'm not that experienced with ArrayLists, I need some basic functions for it 黄瓜爪哇。 我在尝试构建布尔方法时遇到问题 - Cucumber Java. I’m having issues trying to build a boolean method Servlet映射问题 - 我做错了什么? - Servlet mapping issue - what I'm doing wrong? 我是android Java的初学者。 谁能解释代码 - I am beginner in android Java. Can anyone explain the code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM