1. Declares a variable named lengthf that holds whole numbers.
int lengthf;
2. Declares a variable named lengthy that holds real numbers.
3. Declares a constant named F2Y that holds value 1/3.
4. Prompts the user to "Please enter a length expressed in foot: ".
cout %26lt;%26lt;"Please enter a length expressed in foot:";
5. Reads the value from the keyboard and stores it in lengthf.
cin %26gt;%26gt; lengthf;
6. Calculates the equivalent length in yards using the formula yards = 1/3 feet. (Here you must use the named constant instead of the literal value 1/3 and type casting to avoid mixed types in the expression)
7. Rounds the length in yards off to the nearest hundredth (second decimal digit)
8. Formats the output to show 2 decimal digits
9. Prints a message like the one below:
XX feet are equal to YY.YY yards
where XX and YY.YY are the values corresponding to length in feet and length in yards respectively. Notice that length in feet is entered as a whole number
C++ Programming...I need help trying to finish this program, I've started it, but don't know what...?
2) double lengthy ;
3) const float F2Y=1/3;
6) lengthy =(double)lengthf * F2Y;
7) its a lengthy process... search on goole to get this syntax,
9) cout %26lt;%26lt;lengthf +"feet are equal to "+lengthy +" yards
";
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment