import java.util.Scanner;
public class Main {
static double exp=2.718281828;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(true) {
//初始化三个变量
double temp=0;
double dewpoint=0;
double humidex=0;
int flag=0;//标记是哪两个的组合
int flag2=0;//如果是E标记为1,退出
for (int i = 0; i < 2; i++) {
String s=sc.next();
if(s.equals("E")){
flag2=1;
break;
}else if(s.equals("T")) {
temp=sc.nextDouble();
flag+=1;
}else if(s.equals("D")){
dewpoint=sc.nextDouble();
flag+=2;
}else if(s.equals("H")) {
humidex=sc.nextDouble();
flag+=3;
}
}
if(flag2==1) {
break;
}
if(flag==3) {//1+2=3 T D
humidex=temp+0.5555*((6.11*Math.pow(exp, 5417.7530*((1/273.16)-1/(dewpoint+273.16))))-10.0);
}else if(flag==4) {//1+3=4 T H
dewpoint=1/(1/273.16-Math.log(((humidex-temp)/0.5555+10)/6.11)/5417.7530)-273.16;
}else {//2+3=5 D H
temp=humidex-0.5555*((6.11*Math.pow(exp, 5417.7530*((1/273.16)-1/(dewpoint+273.16))))-10.0);
}
System.out.println("T "+String.format("%.1f", temp)+" D "+String.format("%.1f", dewpoint)+" H "+String.format("%.1f", humidex));
}
}
}
POJ 3299 java
最新推荐文章于 2024-06-13 08:37:22 发布