题解 | 温标转换
温标转换
https://www.nowcoder.com/practice/41ceb724a9e843ecad8192cfbea56466
import java.util.Scanner; import java.math.BigDecimal; import java.math.RoundingMode; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double k = scanner.nextDouble(); double c = k - 273.15; double f = c * 1.8 + 32; BigDecimal h = BigDecimal.valueOf(f); // 四舍五入到小数点后6位(满足误差要求) BigDecimal result = h.setScale(9, RoundingMode.DOWN); System.out.println(result); } }
职保镖-扶你上马 文章被收录于专栏
知识分享,交天下朋友,扶你上马,送你一层,职业规划,面试指导、高薪谈判、背调辅助