目前我在C++類中,並且正在學習函數。我們的任務是創建一個程序來計算總成本,包括每個房間的價格(每平方英尺的價格),勞動力和用戶輸入數量給出的每個房間的稅額。這是我的程序,我無法編譯,我不知道爲什麼。感謝任何幫助我的人,我非常感謝。C計算每平方英尺程序的成本
#include <iostream>
#include <iomanip>
using namespace std;
void getdata (int&, int&, int&);
float InstalledPrice (int , int, float);
float totalprice (float);
void printdata (int , int, float);
int main()
{
int length, width, count, x;
float installation, costpersqfoot, price;
cout << "Enter the amount of rooms.\n";
cin >> x;
for(count = x; count != 0; count --)
{
getdata (length, width, costpersqfoot);
InstalledPrice (length, width, costpersqfoot);
totalprice (installation);
printdata (length, width, price);
}
}
void getdata(int & length, int & width, float & costpersqft)
{
cin >> length, width, costpersqft;
}
float InstalledPrice (int length, int width, float costpersqfoot)
{
const float LABOR_COST = 0.35;
float sqfoot;
sqfoot = length * width;
installation = (costpersqfoot * sqfoot) + (LABOR_COST * sqfoot);
}
float totalprice(float installation)
{
const float TAX_RATE = 0.05;
float price;
price = (installation * TAX_RATE) + installation;
}
void printdata(int length, int width, float price)
{
cout << length << " " << width << " " << price << endl;
}
編譯器告訴你什麼是錯誤的?那將是一個開始猜測問題出在哪裏的好地方......雖然在那個時候,你可能不必猜測...... :) – cHao