Q.25 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 n=new Scanner(System.in);
float i,c;
System.out.println(“Enter the height inches=”);
i= n.nextFloat();

c=(float) (i*2.54);

System.out.println(“Height in Centemetrs=”+c);

}

}

Output

run:
Enter the height inches=
4.5
Height in Centemetrs=11.43
BUILD SUCCESSFUL (total time: 4 seconds)

Leave a Reply

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