clwn.net
当前位置:首页 >> JAVA编程将华氏温度转换为摄氏温度 >>

JAVA编程将华氏温度转换为摄氏温度

将华氏温度转换成摄氏温度的Java程序如下:import java.util.Scanner; public class Fahrenheit { public static void main (String []args) { Scanner input =new Scanner(System.in); System.out.print("Enter a degree in Fahrenehit: "); int Fahrenehit=

public class Main { /** * 华氏温度转摄氏温度 * @param tW 华氏温度 * @return 摄氏温度 */ public static float W2C(float tW) { return (tW-32)*5/9; } /** * 摄氏温度转华氏温度 * @param tC 摄氏温度 * @return 华氏温度 */ public static float C2W(float tC

import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;public class TempChangeDemo { private float temp; public float change(float temp) { float c = (float) ((5f/ 9f)* (temp - 32f)); return c; } public static void main(

import java.util.*;public class HtoC{ public static void main(String[] args){ System.out.print("请输入摄氏温度:"); Scanner input=new Scanner(System.in); if(input.hasNextLine()){ System.out.println("华氏温度为:"+(Integer.parseInt(input.nextLine())*9/5+32)); } }}

public class ChangeDegrees { private static void changeDegree(double d) { double degree; degree=(5/9.0)*(d-32); System.out.println(degree); } public static void main(String[] args) { double d = Double.parseDouble(args[0]); ChangeDegrees.changeDegree(d); } }

/** * 华氏温度转换成摄氏温度 * 使用BigDecimal 完整保留精度,不让进度丢失 * @param f * @return */ public double F2C(double f) { BigDecimal F = new BigDecimal(f); BigDecimal factor = new BigDecimal(5.0/9); F = F.subtract(new BigDecimal(32)).multiply(factor); return F.doubleValue(); }

// 摄氏转华氏 public class CToF extends TemperatureConver { private float fTemperature; public CToF() { } public float conver(float cTemperature) { fTemperature = cTemperature * 9 / 5 + 32; return fTemperature; } }

public class Test {public static void main(String args[]){int Fahrenheit = 0;//华氏温度int Celsius = 0;//摄氏温度byte temp[] = new byte[256];//暂时存储键盘的输入信息System.out.print("请输入华氏温度:");try {System.in.read(temp);} catch

import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; public class tempchangedemo { private float temp; public float change(float temp) { float c = (float) ((5f/ 9f)* (temp - 32f)); return c; } public static void main(

仅供参考 package com.kidd.test.zhidao;import java.util.Scanner;/** * Hello world! * */public class Execute { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("请输入一个摄氏温度:"); double c = scanner.nextDouble(); System.out.println("对应的华氏温度:" + (9d / 5d * c + 32d)); }}

网站首页 | 网站地图
All rights reserved Powered by www.clwn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com