Here’s a simple Java program to convert centimeters to feet and inches:
java
import java.util.Scanner;
public class CMToFeetInches {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter length in cm: ");
double cm = scanner.nextDouble();
// Conversion
int feet = (int) (cm / 30.48); // 1 foot = 30.48 cm
double inches = (cm % 30.48) / 2.54; // 1 inch = 2.54 cm
System.out.println(cm + " cm = " + feet + " feet and " + (int)inches + " inches.");
}
}
This program reads the input in centimeters, converts it to feet (1 foot = 30.48 cm), and then calculates the remaining inches (1 inch = 2.54 cm). The result is displayed in feet and inches.