1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sidana [21]
2 years ago
8

Write a java program that prompts the user to input a length expressed in centimeters. The program should then convert the lengt

h 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.
English
1 answer:
lilavasa [31]2 years ago
7 0

The program is an illustration of a sequential program

<h3>What are sequential programs?</h3>

Sequential programs are programs that do not require loop or iteration

<h3>The main program</h3>

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:

brainly.com/question/17970226

You might be interested in
Read the excerpt below and answer the question. "By a faction, I understand a number of citizens, whether amounting to a majorit
Mice21 [21]

A faction means that there is a number of citizens that the could be a minority or a majority but are relevant for what they think. The reason they are united is that they share common interests. There is a major purpose that made them gathered in the first place. And they can have differences with other groups, but all of them must be respected, knowing that beyond any particular interest, there should be just one: the nations best interest.

Federalist N.-10 is an essay that was written by James Madison as part of the Federalist Papers. He understood that there were factions as part of human nature and those factions formed alliances that sometimes worked against the public interest. So in this paper, he questions how to prevent those risks.

4 0
3 years ago
Why do people read reviews?
Zolol [24]

Answer:

so that they may have a better understanding of the thing that they are reading reviews about, and it comes from people who usually have gotten the product or item.

Explanation:

5 0
2 years ago
What is the attitude of the author in transformation peace tward war
nataly862011 [7]
<span>In the poem "Transformation Peace" by Larry Jaffe, he is saying that it takes more courage to show peace than it does to hold a gun and threaten.</span>
7 0
3 years ago
First book written in america
Kobotan [32]
It was called "The Bay Pslam Book" written by Stephen Daye. Published in 1648....
7 0
3 years ago
this child who just wanted to play in the sun at Nyanga is everywhere the child grown to a man treks through all Africa What wor
artcher [175]
Disappointed is what I want to say it is but im not positive. I hope im right!:)
5 0
3 years ago
Read 2 more answers
Other questions:
  • Do you support or oppose kaepernicks action explain maximum
    10·1 answer
  • Which is one difference between a graphic novel and a memoir?
    9·2 answers
  • What adjective best describes the tone in endgame
    11·2 answers
  • Imagine you have found an article by chen, burton, mihaela, and whittinghill. in that article, the authors cite a quote from ham
    12·1 answer
  • Which best explains the purpose of the rhetorical device used in the following
    9·2 answers
  • What methods did Douglass take to learn reading and writing
    8·1 answer
  • IM GIVING 20 FREE POINTS PLUS BRAINLIEST IF YOU GIVE ME THE RIGHT ANSWER! HURRY PLEASE
    15·1 answer
  • Which of the following are examples of inference?
    14·1 answer
  • write a research based essay in which you discuss the causes and effects of gender-based violence (GBV) (300) words .Part B how
    10·1 answer
  • what does dependent mean in these sentences? Baby raccon are totally dependent on their mother when they were born . their mothe
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!