POJ 3299 java

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));
			
		}
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值