Q. Write a program in java to convert a distance in inches into centimeters.[Consider 1 inch = 2.54 cm]
class convert
{
public static void main(String args[])
{
float a;
double c;
Scanner sc=new Scanner(System.in);
System.out.println("enter distence in inch= ");
a=sc.nextFloat();
c=a*2.54;
System.out.println("distance in cm= "+c);
}
}
Output:
enter distance in inch= 12
distance in cm= 30.04
/*if you have any problem, comment below*/
Comments
Post a Comment