Many people think about their height in feet and inches, even in some countries that primarily use the metric system. Write a program that reads a number of feet from the user, followed by a number of inches. Once these values are read, your program should compute and display the equivalent number of centimeters. Hint: One foot is 12 inches. One inch is 2.54 centimeters.
Output:
5 7 | Your height in centimeters is 170.18 |
6 1 | Your height in centimeters is 185.42 |
6 9 | Your height in centimeters is 205.74 |
Subscribe Our Newsletter
import java.io.*;
ReplyDeleteimport java.util.Scanner;
public class TestClass {
public static void main(String[] args) {
int f, i;
double h;
Scanner in = new Scanner(System.in);
f = in .nextInt();
i = in .nextInt();
h = f * 12 * 2.54 + i * 2.54;
System.out.println("Your height in centimeters is " + h);
}
}