Write a program that converts a person’s height from inches to centimeters using the formula 2.54*height.

public static void main(String[] args) {

Scanner x=new Scanner(System.in);

float i,C;

System.out.println(“Enter The Height in Inches = “);

i=x.nextFloat();

C=(float) (i*2.54);

System.out.println(“Height in Centimeters=”+C);

}

Output:

run:

Enter The Height in Inches =

12

Height in Centimeters=30.48

BUILD SUCCESSFUL (total time: 7 seconds)

Leave a Reply

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