C++HW1 - cout << "...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//Assignment #1 //Calculate Cost of Fountain Garden #include <iostream> #include <iomanip> using namespace std; int main () { cout << "Enter the width of the lawn:" ; double width; cin >> width; cout << "Enter the length of the lawn:" ; double length; cin >> length; double total = length * width; double half = (width / 2) * (length / 2); double lawn = (total - half) * 5; double halfwidth = width / 2; double halflength = length / 2; double gravel = half * 8; double fountain = 400; double cost = lawn + gravel + fountain; cout << fixed << setprecision ( 2 );
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout &lt;&lt; &quot; \n\n&quot; ; cout &lt;&lt; setw( 25 ) &lt;&lt; &quot;Lawn Dimensions&quot; &lt;&lt; setw( 8 ) &lt;&lt; width &lt;&lt; setw ( 8 ) &lt;&lt; length &lt;&lt; setw ( 10 ) &lt;&lt; lawn &lt;&lt; endl; cout &lt;&lt; setw( 25 ) &lt;&lt; &quot;Gravel Dimensions&quot; &lt;&lt; setw( 8 )&lt;&lt; setw( 8 )&lt;&lt; halfwidth &lt;&lt; setw( 8 )&lt;&lt; halflength &lt;&lt; setw( 10 )&lt;&lt; gravel &lt;&lt; endl; cout &lt;&lt; setw( 25 ) &lt;&lt; &quot;Fountain&quot; &lt;&lt; setw( 26 )&lt;&lt; fountain &lt;&lt; endl; cout &lt;&lt; setw( 51 ) &lt;&lt; &quot;-----&quot; &lt;&lt; endl; cout &lt;&lt; setw( 25 ) &lt;&lt; &quot;Total&quot; &lt;&lt; setw( 26 )&lt;&lt; cost &lt;&lt; endl; return 0; }...
View Full Document

Ask a homework question - tutors are online