//****************************************************** // Program Convert: This program converts measurements // in feet and inches into centimeters using the // formula that 1 inch is equal to 2.54 // centimeters. //****************************************************** import java.io.*; public class Conversion { static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); static final double CONVERSION = 2.54; static final int INCHES_PER_FOOT = 12; static final int FEET_PER_YARD = 3; public static void main (String[] args) throws IOException { //declare variables int feet; int inches; int yards; int totalInches; double centimeter; //int centimeter; System.out.print("Enter yards: "); //Step 1 System.out.flush(); yards = Integer.parseInt(keyboard.readLine()); 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 " + yards + " yards for yards, " + feet + " for feet " + "and " + inches + " for inches. "); //Step 5 feet = FEET_PER_YARD*yards + feet; totalInches = INCHES_PER_FOOT * feet + inches; //Step 6 System.out.println(); System.out.println("The total number of inches = " + totalInches); //Step 7 centimeter = totalInches * CONVERSION; //Step 8 System.out.println("The number of centimeters = " + centimeter); //Step 9 } }