Algorithm Java code
  1. Create a variable container named inches which can hold integers.
  2. Create a variable container named centimeters which can hold decimal numbers.
  3. Create a constant container named CENT_TO_INCHES which can hold decimal numbers.
  4. Set the constant value of CENT_TO_INCHES to 2.54.
  5. Ask the user for the number of inches and store their answer in the container named inches.
  6. Multiply the value in inches by the value in CENT_TO_INCHES and store in centimeters.
  7. Output the string formed by joining: inches to “ inches = "
  8. Output the string formed by joining: centimeters to " centimeters.".
import java.util.Scanner; // make Scanner available to the computer
/**Calculate Miles Per Gallon
*
* @author Nancy Harris
* @version V1 - 09/05/2012
******************************************************/
public class ConvertInches
{
public static void main (String args[])
{
// declare the containers int inches; double centimeters; final double CENT_TO_INCHES;
// initialize the constant CENT_TO_INCHES = 2.54;

// get the input
// prepare the input device Scanner keyboard; keyboard = new Scanner(System.in); // input is standard input
// prompt the user and get the value
System.out.print("Enter the inches: ");
inches = keyboard.nextInt();
// manipulate the data
centimeters = inches * CENT_TO_INCHES;
// output the result
System.out.print(inches + " inches = ");
System.out.print(centimeters + " centimeters. "); } }