I have to write a java program So basically I have to take
Solution
import java.io.*;
import java.util.*;
class InchesToCms{
public static void main (String[] args)throws Exception{
//1 Inches = 2.54 Centimeters;
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));//to get input creating bf is an object.
System.out.print(\"Enter the inches: \");//asking the input is inches
float inches = Float.parseFloat(bf.readLine());//geting input first in string,so convert into float using parseFloat function.
float cms = inches * 2.54f;//multiplying given input inches and 2.54.
System.out.println(inches + \" inches is \" + cms + \" centimeter(s).\");//display the inches and centimeters.
System.out.print(\"Enter the Centimeters: \");//asking the input is Centimeters.
float CMS = Float.parseFloat(bf.readLine());
System.out.println(\"You entered \" +CMS+ \" centimeter(s).\");//display out put in Centimeters only.
}
}
/* Output:
1) Enter the inches: 11.0
11.0 inches is 27.939999 centimeter(s).
Enter the Centimeters: 2.0
You entered 2.0 centimeter(s).
Explanatin:
This program 1) It takes input in inches and convert into centimeters
2) and Next It takes input in centimters and display the out in the same centimeters.
*/
