Convert Inches to Centimeters
Problem
Write a program to convert a given length in inches to centimeters. (1 inch = 2.54 cm)
Example:
Input: 10
Output: 25.4
Code
import java.util.Scanner;
public class InchesToCentimeters {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double inches = sc.nextDouble();
double cm = inches * 2.54;
System.out.printf("%.2f%n", cm);
}
}inches = float(input())
cm = inches * 2.54
print(f"{cm:.2f}")