攝氏華氏溫度換算
import java.util.Scanner;
import java.util.concurrent.Callable;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("請輸入你要轉換的功能\n1: 攝氏轉華視\n2: 華視轉攝氏");
int inputNumber1 = scanner.nextInt();
if (inputNumber1 == 1) {
System.out.println("請輸入攝氏溫度: ");
double Celsious = scanner.nextDouble();
double Fahrenheit = Celsious*9/5+32.0;
System.out.println("攝氏"+Celsious+"等於華氏"+Fahrenheit);
}
else if (inputNumber1 == 2) {
System.out.println("請輸入華氏溫度: ");
double Fahrenheit = scanner.nextDouble();
double Celsious = (Fahrenheit-32.0)*5/9;
System.out.println("華氏"+Fahrenheit+"等於攝氏"+Celsious);
}
else {
System.out.println("功能選項不正確,請重新輸入");
}
}
}
以下兩張圖是執行後,根據問題回答的內容