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
|
#include <iostream>
#include <cmath>
using namespace std; //introduces namespace standard library
void getdata (int& length, int& width, float& costpersqfoot); //reads the length and width of the room and the cost per square foot
float InstalledPrice(int length, int width, float costpersqfoot); //calculates the installed price taking into account the labor cost
//the labor cost is a symbolic constant
float totalprice(float installation); //finds the total cost using the installed price and the tax rate
void printdata (int length, int width, float price); //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;
void PrintLines (int);
int main()
{
int length, width, costpersqfoot;
float installation, price, LABOR_COST, t, ip;
int count, numLines; //loop control variable
cout << "Input the number for the count." << endl;
cin >> count; //enter number of lines you wants
while (count <= numLines)
{
cin >> length >> width >> costpersqfoot;
getdata (InstalledPrice);
ip = InstalledPrice(t); //find installation cost
totalprice(); //find total cost
printdata (ip, t);
}
system("pause");
return 0;
} //end of main
float installation, costpersqfoot, t, ip;
int length, width;
void getdata (float& t)
{
cout << "Input the length, width, and cost per square foot" << endl;
cin >> t;
}
float InstalledPrice (float t)
{
return (length*width*costpersqfoot) + (length*width*LABOR_COST);
}
float totalprice (float t)
{
return (installation*TAX_RATE);
}
void printdata (int length, int width, float price)
{
cout << "The Installation cost is = " << ip << endl;
cout << "The total price is include tax = " << t << endl;
}
|