/**
* 将磅数转换为千克数。
* 提示用户输入磅数,然后转换成千克并显示结果。
* 一磅等于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-05-11 13:26:46 发布
本文介绍了一个简单的Java程序,该程序能将用户输入的磅数转换为相应的千克数。通过使用标准换算比率(1磅=0.454千克),程序能够帮助用户快速进行单位换算。
1907

被折叠的 条评论
为什么被折叠?



