#include
#include
using namespace std;
int main(){
// These are the costs of the stone in $ per sq ft.
const float gradeACharge = 92.99;
const float gradeBCharge = 78.99;
const float gradeCCharge = 56.99;
const float gradeDCharge = 39.99;
// This is the cost of edging per linear foot
const float finishedEdgeCharge = 4.99;
// There is a charge for polishing the stone prior to delivery
const float polishingCharge = 0.15; // 15% overhead for polishing
const float wastagePercent = 0.2; // 20% wastage is typical
cout << "Welcome to Quinn's Quartzite Quarry Countertop Quoter." << endl;
cout << "This program computes the cost of a single finished"
<< "rectangular countertop piece. " << endl << endl;
cout << "Before running this program you will need the depth" << endl;
cout << "and length of the counter, which edges are to be finished" << endl;
cout << "and the edge style, as well as the grade of stone to be used" << endl;
cout << "and the stone finish. " << endl << endl;
cout << "Please enter the depth of the countertop in inches: ";
float depth;
cin >> depth;
if (depth <= 0){
cout << "Depth must be greater than zero. Returning..." << endl;
return(-1);
}
if (depth > 48){
cout << "Depth must be at most 48 inches. Returning..." << endl;
return(-1);
}
cout << "Please enter the length of the countertop in inches: ";
float length;
cin >> length;
if (length <= 0){
cout << "Length must be greater than zero. Returning..." << endl;
return(-1);
}
if (length > 120){
cout << "Length must be at most 120 inches. Returning..." << endl;
return(-1);
}
cout << "Number of long edges to be finished: ";
int longFinished;
cin >> longFinished;
if ((longFinished < 0)||(longFinished > 2)){
cout << "You can only finish 1 or 2 long edges. Returning..." << endl;
return (-1);
}
cout << "Number of short edges to be finished: ";
int shortFinished;
cin >> shortFinished;
if ((shortFinished < 0)||(shortFinished > 2)){
cout << "You can only finish 1 or 2 short edges. Returning..." << endl;
return (-1);
}
cout << "Please choose a grade of stone:" << endl;
cout << "A) Marble" << endl;
cout << "B) Granite" << endl;
cout << "C) Quartz" << endl;
cout << "D) Soapstone" << endl;
cout << "Selected grade: ";
char stoneGrade;
cin >> stoneGrade;
if ((stoneGrade != 'a') &&
(stoneGrade != 'A') &&
(stoneGrade != 'b') &&
(stoneGrade != 'B') &&
(stoneGrade != 'c') &&
(stoneGrade != 'C') &&
(stoneGrade != 'd') &&
(stoneGrade != 'D')) {
cout << "Unknown grade of stone, returning..." << endl;
return(-1);
}
cout << "Would you like a polished surface (y/n)? ";
char polished;
cin >> polished;
// Now we have all the information we need, compute the cost
// Compute the exact sq ft of stone needed
float sqFtStone = (length * depth)/144;
// Round up and get integer for wastage
float sqFtStoneWithWastage = sqFtStone * (1 + wastagePercent);
int totalSqFtNeeded = static_cast(ceil(sqFtStoneWithWastage));
// Compute the cost of the stone by grade
float stoneSqFtCost = 0;
if ((stoneGrade == 'a')||(stoneGrade == 'A')){
stoneSqFtCost = gradeACharge * sqFtStone;
}
if ((stoneGrade == 'b')||(stoneGrade == 'B')){
stoneSqFtCost = gradeBCharge * sqFtStone;
}
if ((stoneGrade == 'c')||(stoneGrade == 'C')){
stoneSqFtCost = gradeCCharge * sqFtStone;
}
if ((stoneGrade == 'd')||(stoneGrade == 'D')){
stoneSqFtCost = gradeDCharge * sqFtStone;
}
float polishingCost = 0;
bool polishing = false;
if ((polished == 'y') || (polished =='Y')){
polishingCost = stoneSqFtCost * polishingCharge;
polishing = true;
}
// Compute the length of all the finished edges
float finishedEdgeFeet = ((longFinished * length) + (shortFinished * depth))/12;
// Compute the cost of finishing the edges
float finishedEdgeCost = finishedEdgeFeet * finishedEdgeCharge;
float totalCost = finishedEdgeCost + stoneSqFtCost;
// Now print out the results neatly
cout << fixed << setprecision(2) << endl << endl;
cout << setw(15) << "Cost Information" << endl << endl;
cout << setw(35) << "Stone Cost: " << setw(10) << stoneSqFtCost << endl;
cout << setw(35) << "Polishing Cost: " << setw(10) << polishingCost << endl;
cout << setw(35) << "Edge Cost: " << setw(10) << finishedEdgeCost << endl;
cout << setw(35) << "Total: " << setw(10) << stoneSqFtCost + polishingCost + finishedEdgeCost << endl;
cout << endl << endl;
cout << setw(15) << "Fabrication Information" << endl << endl;
cout << setw(35) << "Square Feet of Stone needed: " << setw(4) << totalSqFtNeeded << endl;
cout << setw(35) << "Length: " << setw(4) << length << endl;
cout << setw(35) << "Depth: " << setw(4) << depth << endl;
cout << setw(35) << "Polishing: ";
if (polishing) {
cout << setw(4) << "Yes" << endl;
}
else {
cout << setw(4) << "No" << endl;
}
cout << setw(35) << "Finished edges: " << endl;
cout << setw(35) << "long: " << setw (4) << longFinished << endl << setw(35) << " short: " << setw(4) << shortFinished << endl;
return 0;
}