Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions