Write a program that prompts the user to input a length expressed in centimeters. The program should then convert the length to inches 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 centimeters is equal to 123 inches. 123 inches would be this output:
3 yards, 1 foot, and 3 inches.

hey basically i was assigned this problem. I have no problem with coding this, its just that I have no idea how to do the math. I know you have to do something with the modulus and i know the conversions, but i just am having a hard time with designing the algorithm. Any help would be apprecciated! Thanks!

Post what you have, and people will help out. Otherwise, you may be asking us to do your homework for you, and we've got a rule against that.
Sorry.

As a hint, though: If you're working with ints, division by / gives the answer without remainder. The modulus operator % is the remainder for the same division.
Good luck!

That is definitely NOT me. It may be someone from my same class.

So basically would I just convert centimeters to yards then get the modulus then convert the modulus by feet and then get the modulus of the feet and convert that modulus to centimeters? Im so confused

Whoa, whoa, whoa.
This isn't a coding question after all? Okay, okay... Here's what you do.
Break it down into steps, one item at a time.
This makes the problem more managable and you can write functions based on the item list.
For example:
1. Steal underpants
2...
3. PROFITS!

Don't break it down too far, though. Anything that directly relates to a particular step, such as calculating a value and displaying it, can be put in one step.
...
Anyway, this is how I'd approach this program.

Step 1:
Get user input.

Step 2:
Convert input from centimeters to inches.

Step 3:
Convert inches to yards (A yard is input%36), display yards, return value of inches once the full yards are removed.

Step 4:
Convert remaining inches to feet (inches %12). Display feet, return value of inches remaining.

Step 5:
Display inches remaining.

Step 6:
PROFITS!

That is definitely NOT me. It may be someone from my same class.

read that other thread and use the same suggestions. Or do you want somebody to do your work for you?

drowzeee thank you sooooo much! i've finally gotten my code to work after looking at your suggestions!

And no ancient dragon I was not asking for someone to do the work for me. Like I said I was asking for help regaurding how to approach the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.