/**
* 将磅数转换为千克数。
* 提示用户输入磅数,然后转换成千克并显示结果。
* 一磅等于0.454千克。
* 下面是一个运行示例:
* ————————————————————————————————————
* | Enter a number in pounds: 55.5 |
* | 55.5 pounds is 25.197 kilograms! |
* ————————————————————————————————————
*/
package Test;
import java.util.Scanner;
public class T24 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a number in pounds: ");
double pounds = input.nextDouble();
double kilograms = pounds * 0.454;
System.out.println(pounds + " pounds is " + kilograms + " kilograms!");
}
}
第2章:将磅数转换为千克数
最新推荐文章于 2023-03-06 13:34:28 发布