Anyone that can give me the code to get my program to compile and work ill give u a xbox live 2 month. thanks guys
ALright so basically your suppose to tell the program the length and width of room and cost per sq foot. And the program should calculate the total including labor and tax cost. So basically the program just adds tax and labor the length width and cost per square foot are user entered. The labor and tax cost are both constant. Labor = 0.35 Tax=0.05.
#include <iostream>
#include <iomanip>
using namespace std;
void get_data(int & length,int& width,float costpersqfoot);
float InstalledPrice(int length,int width,float costpersqfoot);
float totalprice(float installion);
void printdata(int length,int width,float price);
const float LABOR_COST=0.35;
const float TAX_RATE=0.05;
int main ()
{
int length,width;
int count;
cout << " Enter number of mesurements to input";
cin >> count;
for (int i=1; i <=count; i++)
{
get_data (length,width);
float Installedprice = length * width * float costpersqfoot + LABOR_COST;
cout << " Your installed price is" <<
setprecision(2) << length * width * float costpersqfoot + LABOR_COST + TAX_RATE << endl;
cout << " Your total price is" <<
There are so many mistakes. Lets start by fixing your functions. what do you think following lines of code mean?
void get_data(int & length,int& width,float costpersqfoot);
get_data (length,width);
I know it won't compile successfully but it will certainly give you some errors. Copy paste your errors here so that I can help you fix them. With out error list I can't. :P
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
usingnamespace std;
constfloat LABOR_COST=0.35;
constfloat TAX_RATE=0.05;
int main ()
{
int length,width;
int count;
float costpersqfoot;
for(;;)
{
std::string input;
cout << "Please enter the cost per square foot: ";
getline(cin, input);
stringstream myStream(input);
if (myStream >> costpersqfoot)
break;
cout << "Invalid, please try again" << endl;
}
for(;;)
{
std::string input;
cout << "Please enter the count: ";
getline(cin, input);
stringstream myStream(input);
if (myStream >> count)
break;
cout << "Invalid, please try again" << endl;
}
for (int i=1; i <= count; ++i)
{
for(;;)
{
std::string input;
cout << "Please enter a valid width: ";
getline(cin, input);
stringstream myStream(input);
if (myStream >> width)
break;
cout << "Invalid, please try again" << endl;
}
for(;;)
{
std::string input;
cout << "Please enter a valid width: ";
getline(cin, input);
stringstream myStream(input);
if (myStream >> length)
break;
cout << "Invalid, please try again" << endl;
}
float basePrice = length * width * costpersqfoot;
float installPrice = basePrice + (basePrice*LABOR_COST);
float totalPrice = installPrice + (installPrice*TAX_RATE);
cout << "Your installed price is " << installPrice << endl;
cout << "Your total price is " << totalPrice << endl;
}
std::cin.get(); //Prevent console from closing.
}
There variables that you didn't exactly explain that I assumed about. Run it a few times to make the functionality is okay. I tried to make it kinda newbie-looking but I'm not used to such a thing anymore. I can also shorten the code here by several lines if need be.
Also, my email is admin@computerquip.com, please email (if still valid) the prize details there or you can PM me through this forum.