I am working on homework and have spent a few hours but can't figure out what is missing from this code. I would appreciate any help to point in the right direction to resolve this.
I need to write a code that converts inches into the equivalent yards, feet, and inches. When I run the program it says I haven't defined yards. I thought I did but clearly am missing something but after hours of online searching while looking through my textbook I just don't understand what's wrong.
Each Google search takes me to more difficult ways to code this answer but I need the basics as I'm in an intro class to C++.
Thank you to anyone that can help!
#include <iostream>
using namespace std;
int main( )
{
int userInches;
int feet, yards, inches;
cout << " Enter distance in inches:\n";
cin >> userInches;
// converts the number of inches to yards, feet, and inches
cout << "The distance of " << inches << " is the same as the distance of " << yards << " yards " << "," << feet << " feet " << " , and " << inches << " inches." << endl;
return 0;
}
When i run the code i get:
Enter the distance in inches:
140
The distance of 8 is the same as the distance of 0 yards ,2 feet , and 8 inches.
Process returned 0 (0x0) execution time : 24.600 s
Press any key to continue.
but it needs to read as:
Enter the distance in inches:
140
The distance of 140 inches is the same as the distance of 3 yards, 2 feet and 8 inches