Question #38556

Write a java program to convert your height in cm to feet and inches
1

Expert's answer

2014-01-29T15:14:55-0500

//Answer on Question #38556, Programming, Java

import java.util.Scanner;


public class ConvertHeightFeet {
    //main function
    public static void main(String[] args) {
        //Scanner for input
        Scanner input = new Scanner(System.in);
        double heightincm; //variable for heightincm
        double heightinfeet; //variable for heightinfeet
        double heightininches; //variable for heightininches
        System.out.print("Enter height in cm: "); //prompt user to enter height in cm
        heightincm = input.nextDouble(); //read height in cm
        heightinfeet = 0.0328084 * heightincm; //calculate heightinfeet
        heightininches = 0.393701 * heightincm; //calculate heightininches
        //show result
        System.out.println("Enter height in feet: "+heightinfeet);
        System.out.println("Enter height in inches: "+heightininches);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS