首页 > 试题广场 >

(将摄氏溫度转换为华氏溫度)编写程序,从控制台读人doubl

[问答题]
(将摄氏溫度转换为华氏溫度)编写程序,从控制台读人double 型的摄氏温度,然后将其转换为 华氏温度,并且显示结果。转换公式如下所示:
华氏溢度_(9/5)* 摄氏a廋 +32 
提示:在 Java中,9/5 的结果是1, 但是 9.0/5 的结果是1.83 
下面是一个运行示例:


下面是一个运行示例
import java.util.Scanner;

public class Test1 {
    public static void main(String[] w) {
        while(true) {
        System.out.print("请输入一个摄氏温度进行转换:");
        Scanner sc = new Scanner(System.in);
        double cel = sc.nextDouble();
        double fah = (9.0 / 5) * cel + 32;
        System.out.println(cel + "摄氏度等于 " + fah + " 华氏度"+"\n");
}
    }
        }
发表于 2021-01-29 12:34:11 回复(1)

华氏温度_(9/5)* 摄氏度 +32

发表于 2021-05-02 22:38:34 回复(0)
import java.util.Scanner;  public class ttttTtt { public static void main(String[] args) { //Let's get it Scanner in=new Scanner(System.in);  System.out.print("Enter a degree in Celsius:");  double sheshi=in.nextDouble();  double huashi=(9.0/5)*sheshi+32;  System.out.println(sheshi+"Celsius is "+huashi+" Fahrenheit");  }
}
发表于 2021-01-13 14:51:39 回复(0)
import java.util.Scanner;

public class Test2_1 {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        System.out.println("输入摄氏度度数: ");
        double C = input.nextDouble();
        System.out.println("你输入的摄氏度度数是 " + C +" , 对应的华氏温度是 " + (9.0/5) * C + 32);

    }
}

发表于 2020-11-12 08:40:29 回复(0)
import java.util.Scanner;
public class Test{
    public static void main(String [] args){
        test5();
        
    }
    public static void test5(){
        System.out.print("Enter a degree in Celsius:");
        Scanner sc = new Scanner(System.in);
        while(!sc.hasNext("0")){
        double a = sc.nextDouble();
        double b = a*(9.0/5)+32;
        System.out.println(a+" Celsius is " + b + "Fahrenheit");
        System.out.println("Enter 0 exit!");
        System.out.print("Enter a degree in Celsius:");
        }
        sc.close();
        
            

    }
发表于 2020-01-31 18:47:08 回复(0)