|
|
|
© 1998 by Bobby Griggs.
// Program name: Concrete
// Win32 console application to satisfy programming test requirement
// for Chapter 3.
// Write a program to compute the cost of concrete for pouring a
// basketball court. Price should be a constant in the program.
// The programmer has a choice as to whether to make the depth of
// the concrete a constant. The depth of the concrete is to be 4
// inches. The user should be prompted to enter the length and
// width of the court.
#include < iostream.h >
#include < stdio.h >
#include < iomanip.h >
void main()
{
const double PRICE = 12.00; // price per cubic yard
const double DEPTH = 4.0 / 36.0; // depth in inches
double court_length,court_width,cost;
cout << setiosflags(ios::fixed) << setprecision(2);
cout << "Enter length of court (in feet) ... ";
cin >> court_length;
cout << endl;
cout << "Enter width of court (in feet) ... ";
cin >> court_width;
cout << endl << endl;
// convert length and width to yards
court_length = court_length / 3;
court_width = court_width / 3;
// compute cost of concrete
cost = court_length * court_width * DEPTH * PRICE;
cout << "The concrete will cost $"<< cost << "!" << endl << endl;
cout << "Hit enter to continue ..." << endl;
getchar();
return;
}
|