//****************************************************** // Program Convert: This program converts measurements // in feet and inches into centimeters using the // formula that 1 inch is equal to 2.54 // centimeters. // // Change it to ask for height and convert to meters and centimeters. // //****************************************************** import java.io.*; public class Conversion { static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); static final double CENTIMETERS_PER_INCH = 2.54; static final int INCHES_PER_FOOT = 12; public static void main (String[] args) throws IOException { //declare variables int feet; int inches; int totalInches; double centimeter; //int centimeter; System.out.print("Enter feet: "); //Step 1 System.out.flush(); feet = Integer.parseInt(keyboard.readLine()); //Step 2 System.out.println(); System.out.print("Enter inches: "); //Step 3 System.out.flush(); inches = Integer.parseInt(keyboard.readLine()); //Step 4 System.out.println(); System.out.println("The numbers you entered are " + feet + " for feet " + "and " + inches + " for inches. "); //Step 5 totalInches = INCHES_PER_FOOT * feet + inches; //Step 6 System.out.println(); System.out.println("The total number of inches = " + totalInches); //Step 7 centimeter = (INCHES_PER_FOOT * feet + inches) * CENTIMETERS_PER_INCH; //Step 8 System.out.println("The number of centimeters = " + centimeter); //Step 9 } }