-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInchesToCentimeters.java
30 lines (21 loc) · 1.11 KB
/
InchesToCentimeters.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*Write an interactive console program in a class named InchesToCentimeters that prompts the user to read in two input values: a number of feet, followed on a separate line by a number of inches. The program should convert this amount to centimeters. Here is a sample run of the program (user input is shown like this):
This program converts feet and inches to centimeters.
Enter number of feet: 5
Enter number of inches: 11
5ft 11in = 180.34cm
*/
import java.util.Scanner;
public class InchesToCentimeters {
public static void main(String[]args){
System.out.println("This program converts feet and inches to centimeters.");
Scanner scanner = new Scanner(System.in);
System.out.print("Enter number of feet: ");
int feet = scanner.nextInt();
System.out.print("Enter number of inches: ");
int inches = scanner.nextInt();
double fttocm = feet * 30.48;
double inctocm = inches * 2.54;
double cm = fttocm + inctocm;
System.out.println(feet + "ft " + inches + "in = " + cm + "cm");
}
}