readdata - c int main () { int length = 20.75; // measured...

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

View Full Document Right Arrow Icon
// file: readdata.cpp // author; N. Dale // adapted by: j. dzuback // modifed by: /* ***************************************** The program provides a test bed for a variety of cin statements in combination with different data inputs supplied by the user. The program calculates the cost of a sheet of glass based on the dimensions (length and width) and price per square foot. All values to be entered by the user. ***************************************** */ #include <iostream> #include <iomanip> using namespace std; u const int IN_PER_FTSQ = 144;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: c int main () { int length = 20.75; // measured in inches int width = 32; // measured in inches float price = 46; // sold by square foot float cost; cout &lt;&lt; fixed &lt;&lt; showpoint; /* TO BE FILLED IN. */ cout &lt;&lt; &quot;Width: &quot; &lt;&lt; setw(5) &lt;&lt; width &lt;&lt; &quot; Length: &quot; &lt;&lt; setw(5) &lt;&lt; length &lt;&lt; &quot; Price: &quot; &lt;&lt; setw(6) &lt;&lt; setprecision(2) &lt;&lt; price &lt;&lt; endl; cin &gt;&gt; width &gt;&gt; length &gt;&gt; price; cost = ((width * length) / IN_PER_FTSQ) * price; cout &lt;&lt; &quot;The cost of the glass is $&quot; &lt;&lt; setw(6) &lt;&lt; cost &lt;&lt; endl; return 0; }...
View Full Document

This note was uploaded on 02/08/2011 for the course CSC 101 taught by Professor Joedzuback during the Spring '11 term at Union County.

Ask a homework question - tutors are online