import java.util.Scanner;

/** CentimetersToInches.
 * This program will convert an input decimal number of centimeters
 * to its equivalent feet and inches.
 * Taking Pg42 of Think Java code for Convert class and adding methods to it.
 * @author Alvin Chao - refactoring Chris Mayfield and Alan Downey
 * @version 1-27-17
 * Acknowledgements: Prof Mayfield gave me help with the calculations for this 
 * assignment.  I received no unauthorized help on this assignment.
 */

public class CentimetersToInches {

    /**
     * Main Method.
     * @param args command line arguments - not used.
     */

    public static void main(String[] args) {
        //Declarations
        Scanner in;
        double cm;
        int feet;
        int inches;
        int remainder;
        //Initialization
        in = new Scanner(System.in);
        //Input section
        System.out.print("Enter an integer to convert from "
            + "Centimeters to Inches");
        // prompt the user and get the value
        System.out.print("Exactly how many cm? ");
        cm = in.nextDouble();
        // Calculation section
        inches = cmToInches(cm);
        // Output section
        outputResults(cm, inches);
    }

    /**
     * cmToInches - covert centimeters to inches.
     * @param centimeters # of cm to convert
     * @return int number of inches in the cm given.
     */
    public static int cmToInches(double centimeters) {
        int returnInches;
        final double CM_PER_INCH = 2.54;
        returnInches = (int) (centimeters / CM_PER_INCH);  
        return returnInches;
    }

    /**
     * outputResults - Output the # of feet and inches in the given cm.
     * @param cm - centimeters to be output
     * @param in - # of inches to convert
     */
     
    public static void outputResults(double cm, int in) {
        final int IN_PER_FOOT = 12;
        int feet;
        int remainder;
        feet = in / IN_PER_FOOT; 
        remainder = in % IN_PER_FOOT;
        System.out.printf("%.2f cm = %d ft, %d in\n",
            cm, feet, remainder);
    }
}
