Write a program that inputs pounds from the user and converts it into kilograms.

 

public static void main(String[] args) {

Scanner x=new Scanner(System.in);

float pounds,kg;

System.out.println(“Enter weight in pounds = “);

pounds=x.nextFloat();

kg=(float) (pounds*0.454);

System.out.println(“Kilograms=”+kg);

}

Output:

run:

Enter weight in pounds =

45

Kilograms=20.43

BUILD SUCCESSFUL (total time: 3 seconds)

Leave a Reply

Your email address will not be published. Required fields are marked *