Skip to content
← Back to Community
I am having trouble understanding this website for a college class
Profile icon
CeciliaLeal

the teacher wants us to make a program to convert feet into yards.
can someone teach me or help me how to understand how to do that??

thank you!!!

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
CeciliaLeal
Comments
hotnewtop
Profile icon
Coder100

So, from what I understand:

#include <iostream> int main() { double feet; std::cout << "Enter in feet: "; std::cin >> feet; std::cout << "Your length in yards is " << feet / 3; }

working repl

Profile icon
CeciliaLeal

but what do I put or how do I used I am so confused and I love math and I still don't understand it
@Coder100

Profile icon
Coder100

wdym what part is confusing? We get the input and then divide that by 3 because there are 3 feet in a yard. @CeciliaLeal

Profile icon
CeciliaLeal

oh okay I understand it know thank you!! @Coder100

Profile icon
Coder100

no problem!! Please mark as correct answer! @CeciliaLeal

Profile icon
Coder100

Sure! What language?

Profile icon
CeciliaLeal

Problem: You are asked to write a program to receive a length expressed in feet, convert it to
yards, and show the result on the screen.
The formula for converting a length expressed in feet to yards is:
length in yards = 1/3 x length in feet
Your solution must ask the user to enter the length in feet at the keyboard and then calculate and display the resulting length in yards. You must ask for and display the first name of the person using your program too.
------------------------------------------------------------------------------------------------------------------------ Your task: implement in C++ the algorithm solution shown below. ------------------------------------------------------------------------------------------------------------------------
Algorithm solution (in pseudocode):
To solve this problem your program must perform the following tasks:
Declare a variable named user_name that holds text.
Declare variables named length_feet and length_yards that hold single precision real numbers. Prompt the user to enter his/her first name.
Get the name and store it in the corresponding variable.
Prompt the user to enter the length in feet.
Get the length from the keyboard and store it in the corresponding variable.
Calculate the length in yards using the formula exactly as provided above and assign the result to the corresponding variable.
Display on the screen the following message:
“Hi,” user_name
length_feet, " feet are equal to ", length_yards, " yards"
The program must compile without errors or warnings. Try to work on it before the lab so you can discuss with your teammate your solutions in order to submit the best of both them.
I am posting the executable of my solution for your reference. Please run it and ensure that your program works like mine. Try the values 9, 9.6, 10, 11, 11.25, and 12.25. Is there anything that gets your attention? Run my program and yours using the same input data and compare the results to see if they match. The input and output formatting must be similar to the one used in my sample [email protected]

Profile icon
Coder100