The Wall
October 18, 2011
Ray Panko gives this exercise as a test for the accuracy of spreadsheet development; in his tests he found 62 errors in 150 spreadsheet solutions (some spreadsheets contained more than one error), which he finds is typical of spreadsheet users—hopefully professional programmers make fewer errors:
You are to build a spreadsheet model to help you create a bid to build a wall. You will offer two options — lava rock or brick. Both walls will be built by crews of two. Crews will work three 8-hour days to build either type of wall. The wall will be 20 feet long, 6 feet tall, and 2 feet thick. Wages will be $10 per hour. You will have to add 20% to wages to cover fringe benefits. Lava rock will cost $3 per cubic foot. Brick will cost $2 per cubic foot. Your bid must add a profit margin of 30% to your expected cost.
Your task is to write a program that prompts the user for input of the various parameters—wall dimensions, crew days, rock cost, and so on—and prints a neat calculation of the bid price for the wall. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Here is my solution in C++, I’m a beginner so I’m sure there are plenty of mistakes, but pointers would help me out!
#include “stdafx.h”
#include
float MaterialCost(int x)
{
using namespace std;
//This switch compares the choice selected previously by the user and then
//returns the appropriate price
switch (x)
{
case 1:
return 2.0;
break;
case 2:
return 3.0;
break;
default:
cout << "Error, closing!";
cin.get();
cin.ignore();
exit (1);
}
}
int main()
{
using namespace std;
//Getting material of wall
cout << "What will this wall be made of? Make a selection from the list below:\n\n";
cout << "1. Brick\n";
cout <> nMaterialType;
//Setting cost per cubic foot of materials
float fMaterialCost;
fMaterialCost = MaterialCost(nMaterialType);
//Getting height of wall
cout <> fWallHeight;
//Getting length of wall
cout <> fWallLength;
//Getting Width of wall
cout <> fWallWidth;
//Setting total cubic feet of wall
float fCubicFeet;
fCubicFeet = fWallLength*fWallHeight*fWallWidth;
//Get crew number
cout <> nLaborers;
//Get crew wages per hour
cout <> fWagesPerHour;
//get fringe benifits
cout <> nFringeBenefits;
//get days project will take
cout <> nDays;
//Calculates desired profit margin
cout <> nProfitMargin;
//Calculate total worker cost by taking workers times days times wages then adding benefits on top
float fTotalWages =((nLaborers*fWagesPerHour)*((float).01*nFringeBenefits+1))*(nDays*8);
//Calculate total material cost
float fTotalMaterialCost=(fMaterialCost*fCubicFeet);
//Calculate final project cost plus profit margin
float fProjectCost=((fTotalMaterialCost+fTotalWages)*(nProfitMargin*(float).01+1));
cout << "######################################################\n";
cout << "#\t\t—–Bid for Wall—–\n";
cout << "# Materials:\t\t\t\t\t\n";
cout << "#\tLength in feet:\t\t\t$" << fWallLength << "\n";
cout << "#\tHeight in feet:\t\t\t$" << fWallHeight << "\n";
cout << "#\tWidth in feet:\t\t\t$" << fWallWidth << "\n";
cout << "#\tTotal cubic feet:\t\t$" << fCubicFeet << "\n";
cout << "#\tCost per cubic foot:\t\t$" << fMaterialCost << "\n";
cout << "#\tTotal:\t\t\t\t$" << fTotalMaterialCost << "\n";
cout << "#—————————————————–\n";
cout << "# Labor\n";
cout << "#\tCrew Size:\t\t\t$" << nLaborers << endl;
cout << "#\tDays Worked:\t\t\t$" << nDays << endl;
cout << "#\tCrew Wages Per Hour:\t\t$" << fWagesPerHour << endl;
cout << "#\tTotal Wages:\t\t\t$" << fTotalWages/((float).01*nFringeBenefits+1) << endl;
cout << "#\tFringe benefits:\t\t$" << fTotalWages-(nLaborers*fWagesPerHour) << endl;
cout << "#\tTotal Labor Cost:\t\t$" << fTotalWages << endl;
cout << "#—————————————————–\n";
cout << "# Totals:\n";
cout << "#\tTotal Cost:\t\t\t$" << fTotalMaterialCost+fTotalWages << endl;
cout << "#\tMarkup:\t\t\t\t$" << fProjectCost-(fTotalMaterialCost+fTotalWages) << endl;
cout << "#\n";
cout << "#\tBid Price:\t\t\t$" << fProjectCost << endl;
cout << "#—————————————————–\n";
cout << "######################################################";
cin.get();
cin.ignore();
return 0;
}
I can’t believe I “forgot” to read your blog considering that I found it three months earlier. Also busy with do the job I guess. Anyways I have it bookmarked now to become confident that I get notified as soon as you put some new content up.