首页 > 试题广场 >

(将磅转换为千克)编写程序,将磅数转换为千克数。程序提示用

[问答题]
 (将磅转换为千克)编写程序,将磅数转换为千克数。程序提示用户输人磅数,然后转换成千克并 显示结果。一磅等于 0.4S4 千克。下面是一个运行示例: 

package AA;
import java.util.Scanner;
public class ah {
    public static void main(String[] args){
            double a;
            System.out.print("Enter a number in pounds:");
            Scanner in=new Scanner(System.in);
            a=in.nextDouble();
            double b=0;
            b=a*0.454;
            System.out.println(a+"pound is"+b+"kilograms");
    }
}

编辑于 2021-03-31 11:24:28 回复(0)
import java.util.Scanner;

public class stu13 {
    public static void main(String[]args){
        Scanner scanner=new Scanner(System.in);
        double pound=scanner.nextDouble();
        double kilograms=pound*0.454;
        System.out.println(pound+"pounds is"+ kilograms+" kilograms");
        }
    }


发表于 2020-12-28 00:01:11 回复(0)