Question: Write a (c++) program that prompts the user to input a length expressed in centimeters. The program should then convert the length to inches (to

"Write a (c++) 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. For example, suppose the input for centimeters is 312. To the nearest inch, 312 centimeter sis equal to 123 inches. 123 inches would thus be output as: 3 yard(s), 1 feet (foot), and 3 inch(es). It should not be output as: 2 yard(s), 4 feet (foot) 3 inch (es)."

I can convert centimeters to inches, but then I do not know how to convert those inches in the program to the length expressed in yards/feet/inches. So far this is what I have:

//Given length in centimeters this program outputs that length in yards,feet

//and inches.

#include

using namespace std;

int main()

{

int centimeters; //variable to store centimeters total

int inches;

int yards;

cout << " Enter total centimeters and press enter "; //prompts user to enter total centimeters

cin >> centimeters; //stores value entered by user

cout << centimeters << " centimeters = "; //output the value of centimeters and the equal sign

cout << centimeters * .039 << " inches " << //output inches

cout << inches / 36 << " yards " << //output yards

cout << yards * 0.032 << " feet " <

system("pause");

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!