1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
//include libraries
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std; //introduces namespace standard library
//prototypes
void getdata (int&, int&, float&); //reads the length and width of room and cost per square foot
float InstalledPrice (int, int, float); //calculates the installed price taking into account the labor cost.
//labor cost is a symbolic constant
float totalprice (float); //finds the total cost using the installed price and the tax rate
void printdata (int, int, float); //prints the length, width, and total cost for each data set
const float LABOR_COST = 0.35; //$0.35 per square foot
const float TAX_RATE = 0.05;
int main()
{ //start of main
int length, width; //declare length and width of type int
float installation, total, price, costpersqfoot; //declare installation cost and total cost of type float
int num;
const int MAXCOUNT = num; //read count for the loop
int count;
for (count = 0; count < MAXCOUNT; count++) //for loop based on the count
{ //start of for loop
cout<< "Enter a number for the count: " <<endl;
cin>> num;
getdata (length, width, costpersqfoot); //call get_data
installation = InstalledPrice (length, width, costpersqfoot); //find the installation cost
total = totalprice (installation); //find total cost
printdata (length, width, price); //write the result with the printdata procedure
} //end for loop
system("pause");
return 0;
} //end of main
//define functions here, two void and two regular
void getdata (int& length, int& width, float& costpersqfoot)
{
cout<< "Please enter length, width, and cost per square foot of the room\n";
cin >> length >> width >> costpersqfoot;
}
float InstalledPrice (int length, int width, float costpersqfoot)
{
return (length*width*costpersqfoot) + (length*width*LABOR_COST); //formula to find installation cost with LABOR_COST
}
float totalprice (float installation)
{
return (installation*TAX_RATE); //finding total cost with tax
}
void printdata (int length, int width, float price)
{
cout<< "The cost for installation is = " << installation << endl;
cout<< "The total cost with tax is = " << total << endl;
}
|