[英]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.