Write a java program that prompts the user to input a length expressed in centimeters. The program should then convert the length to inches (to the nearest inch) and output the length expressed in yards, feet, and inches, in that order (all three formats). For example, suppose the input for centimeters is 312. To the nearest inch, 312 centimeters is equal to 123 inches. So 123 inches would then be output as 3 yards, 1 foot, and 3 inches It should not output as: 2 yards, 4 feet and 3 inches = 10 feet, 3 inches = 10.25 feet.

Respuesta :

The program is an illustration of a sequential program

What are sequential programs?

Sequential programs are programs that do not require loop or iteration

The main program

The program written in Java, where comments are used to explain each line is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 //This creates a Scanner object

 Scanner input = new Scanner(System.in);

 //This prompts the user for length in cm

 System.out.print("Length (cm): ");

 //This gets the input for length

 int lengthCM = input.nextInt();

 //This converts the length to inches

 int lengthInches = (int)(Math.round(lengthCM/2.54));

 //This converts the length to yards

 int lengthYard = lengthInches/36;

 //This converts the remaining length to feet

 int lengthFeet = (lengthInches -36 * lengthYard)/12;

 //This calculates the remaining inches

 lengthInches = lengthInches - lengthYard * 36 - lengthFeet * 12;

 //This prints the required output

 System.out.print(lengthYard+" yards, "+lengthFeet+" feet and "+lengthInches+" inches");

}

}

Read more about sequential programs at:

https://brainly.com/question/17970226

RELAXING NOICE
Relax