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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//Constants
const float LABOR = 1.65,
TAX_RATE = 0.06825;
//Prototypes
int setdata(int, int, int, int, int, int, int);
float calculations(float, float, float,
float, float, float,
const float, float, float);
float calcinstalled(float, float, float);
float calcsubtotal(float, float, float);
float calctotal(float, float, float, float);
float showresult(string ,string, int, int, int, int, int,
int, float, const float, float,
float, float, float, float, float,
float, float);
int heading(string,string, int);
int measurements(int, int, int, int, int, string);
float charges(float, float, const float, float,
float, float, float, float, float, float);
int main()
{
string name;
string dash;
int idNum, lengthFt, lengthInch, widthFt,
widthInch, fixLength, fixWidth, area;
float carpetPrice, discount, totCarpetPrice, subtotal, taxAmt, total,
installPrice, discountPrice, laborPrice, laborTot;
// INPUT SECTION
cout << "Customers' Name : "; getline(cin, name);
cout << "Customers' ID# : "; cin >> idNum;
cout << "Length of Room (Feet) : ";cin >> lengthFt;
cout << "Length of Room (Inches) : "; cin >> lengthInch;
cout << "Width of Room(Feet) : ";cin >> widthFt;
cout << "Width of Room(Inches) : ";cin >>widthInch;
cout << "Cost / Square Foot : "; cin >>carpetPrice;
cout << "Percentage of Discount : "; cin >>discount;
calculations( carpetPrice, laborTot, carpetPrice,
totCarpetPrice, discount, subtotal,
TAX_RATE, taxAmt, total);
fixLength = lengthFt + (lengthInch/12);
fixWidth = widthFt + (widthInch/12);
area = fixLength * fixWidth;
laborTot = LABOR * area;
showresult(name, dash, idNum, lengthFt, lengthInch, widthFt, widthInch,area, carpetPrice, totCarpetPrice, LABOR, laborTot,
laborPrice, discount, installPrice, subtotal, taxAmt, total);
return 0;
}
//Definitions
float calculations(float installPrice, float laborTot, float carpetPrice,
float totCarpetPrice, float discount, float subtotal,
const float TAX_RATE, float taxAmt, float total)
{
calcinstalled(installPrice, laborTot, carpetPrice);
calcsubtotal(installPrice, discount, subtotal);
calctotal(subtotal, TAX_RATE, taxAmt, total);
}
float calcinstalled(float installPrice, float laborTot, float carpetPrice)
{
installPrice = laborTot + carpetPrice;
}
float calcsubtotal(float installPrice, float discount, float subtotal)
{
subtotal = installPrice - (discount/100);
}
float calctotal(float subtotal, float TAX_RATE, float taxAmt, float total)
{
taxAmt = subtotal * TAX_RATE;
total = subtotal + taxAmt;
}
float showresult(string name,string dash, int idNum, int lengthFt, int lengthInch, int widthFt, int widthInch,
int area, float carpetPrice, const float LABOR, float laborTot,
float totCarpetPrice, float laborPrice, float discount, float installPrice, float subtotal,
float taxAmt, float total)
{
cout << fixed << showpoint << setprecision(2);
heading(name,dash, idNum);
measurements(lengthFt, lengthInch, widthFt, widthInch, area, dash);
charges(carpetPrice, totCarpetPrice, LABOR, laborTot,
laborPrice, discount, installPrice,
subtotal, taxAmt, total);
}
int heading(string name, string dash, int idNum)
{
system("CLS");
dash.assign(50, '-');
cout << "\t\tPassaic County Community Carpet Center\n";
cout << "\t\t\t 123 Main Street\n";
cout << "\t\t\tPaterson, NJ 07505\n\n";
dash.assign(50, '-');
cout <<"Customer Name:\t\t" << name <<endl;
cout <<"Customer Number:\t" << idNum << endl;
}
int measurements(int lengthFt, int lengthInch, int widthFt, int widthInch,
int area, string dash)
{
cout << "\nRoom Measurements:\n\n\t\t\t";
cout << "Length:\t" << lengthFt << "' " << lengthInch << "\"" << endl;
cout << "\t\t\tWidth:\t" << widthFt <<"'" << widthInch << "\"" << endl;
cout << "\t\t\tArea:\t" << area<<" Sq/Ft"<< endl;
dash.assign(50, '-');
}
float charges(float carpetPrice, float totCarpetPrice, const float LABOR, float laborTot,
float laborPrice, float discount, float installPrice,
float subtotal, float taxAmt, float total)
{
cout << "Charges:\n";
cout << "\tDescription\t\tCost/SQ Ft\t\tCharges/Room\n";
cout << "\t------------\t\t----------\t\t------------\n";
cout << "\tCarpet\t\t\t$" << carpetPrice << "\t\t\t$" << totCarpetPrice << endl;
cout <<"\tLabor\t\t\t$" << LABOR << "\t\t\t$" << laborTot << endl;
cout <<"\n\tInstalled Price\t\t\t\t\t$" << installPrice << endl;
cout <<"\n\tDiscount\t\t" << discount/100 << "\t\t\t$" << installPrice*(discount/100) << endl;
cout <<"\n\n\tSubtotal\t\t\t\t\t$" << subtotal << endl;
cout <<"\tTax\t\t\t\t\t\t$" << taxAmt << endl;
cout <<"\n\n\tTotal\t\t\t\t\t\t$" << total;
}
|