x; 对于(计数=x;计数!=0;计数--) { getdata(长度、宽度、costpersqfoot); 安装价格(长度、宽度、成本/英尺); 总价(安装费); 打印数据(长度、宽度、价格); } } void getdata(整数和长度、整数和宽度、浮点和成本) { cin>>长度、宽度、成本和QFT; } 浮动安装价格(整数长度、整数宽度、浮动成本) { 固定浮动人工成本=0.35; 漂浮平方英尺; sqfoot=长度*宽度; 安装=(成本/平方英尺)+(人工成本/平方英尺); } 浮动总价(浮动安装) { 固定浮动税率=0.05; 浮动价格; 价格=(安装*税率)+安装; } 无效打印数据(整数长度、整数宽度、浮动价格) { 可能有许多错误:,c++,function,compiler-construction,C++,Function,Compiler Construction" /> x; 对于(计数=x;计数!=0;计数--) { getdata(长度、宽度、costpersqfoot); 安装价格(长度、宽度、成本/英尺); 总价(安装费); 打印数据(长度、宽度、价格); } } void getdata(整数和长度、整数和宽度、浮点和成本) { cin>>长度、宽度、成本和QFT; } 浮动安装价格(整数长度、整数宽度、浮动成本) { 固定浮动人工成本=0.35; 漂浮平方英尺; sqfoot=长度*宽度; 安装=(成本/平方英尺)+(人工成本/平方英尺); } 浮动总价(浮动安装) { 固定浮动税率=0.05; 浮动价格; 价格=(安装*税率)+安装; } 无效打印数据(整数长度、整数宽度、浮动价格) { 可能有许多错误:,c++,function,compiler-construction,C++,Function,Compiler Construction" />

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; } #包括 #包括 使用名称空间std; void getdata(int&,int&,int&); 浮动安装价格(整数,整数,浮动); 浮动总价格(浮动); 无效打印数据(int、int、float); int main() { 整数长度、宽度、计数、x; 浮子安装、成本、价格; cout>x; 对于(计数=x;计数!=0;计数--) { getdata(长度、宽度、costpersqfoot); 安装价格(长度、宽度、成本/英尺); 总价(安装费); 打印数据(长度、宽度、价格); } } void getdata(整数和长度、整数和宽度、浮点和成本) { cin>>长度、宽度、成本和QFT; } 浮动安装价格(整数长度、整数宽度、浮动成本) { 固定浮动人工成本=0.35; 漂浮平方英尺; sqfoot=长度*宽度; 安装=(成本/平方英尺)+(人工成本/平方英尺); } 浮动总价(浮动安装) { 固定浮动税率=0.05; 浮动价格; 价格=(安装*税率)+安装; } 无效打印数据(整数长度、整数宽度、浮动价格) { 可能有许多错误:

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; } #包括 #包括 使用名称空间std; void getdata(int&,int&,int&); 浮动安装价格(整数,整数,浮动); 浮动总价格(浮动); 无效打印数据(int、int、float); int main() { 整数长度、宽度、计数、x; 浮子安装、成本、价格; cout>x; 对于(计数=x;计数!=0;计数--) { getdata(长度、宽度、costpersqfoot); 安装价格(长度、宽度、成本/英尺); 总价(安装费); 打印数据(长度、宽度、价格); } } void getdata(整数和长度、整数和宽度、浮点和成本) { cin>>长度、宽度、成本和QFT; } 浮动安装价格(整数长度、整数宽度、浮动成本) { 固定浮动人工成本=0.35; 漂浮平方英尺; sqfoot=长度*宽度; 安装=(成本/平方英尺)+(人工成本/平方英尺); } 浮动总价(浮动安装) { 固定浮动税率=0.05; 浮动价格; 价格=(安装*税率)+安装; } 无效打印数据(整数长度、整数宽度、浮动价格) { 可能有许多错误:,c++,function,compiler-construction,C++,Function,Compiler Construction,一,。 cin>>长度、宽度、成本和QFT 恐怕这是不允许的 应该是 cin >> length >> width >> costpersqft; 此外,installedPrice和totalPrice函数应根据其原型返回一些浮点值 float InstalledPrice (int length, int width, float costpersqfoot) { const float LABOR_COST = 0.35; float

一,。 cin>>长度、宽度、成本和QFT

恐怕这是不允许的

应该是

cin >> length >> width >> costpersqft;
此外,installedPrice和totalPrice函数应根据其原型返回一些浮点值

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);
}

什么是安装?此函数不可见。

我看到一些编译错误

get data函数接受3个int引用作为参数,但您要发送2个int和一个float

在InstalledPrice函数中,从未声明安装变量。

还有一些错误

float totalprice(float installation)
{
    const float TAX_RATE = 0.05;
    float price;
    price = (installation * TAX_RATE) + installation;
}
出于某种原因,初学者在学习函数时往往会忽略
return
的概念

float totalprice(float installation)
{
    const float TAX_RATE = 0.05;
    return (installation * TAX_RATE) + installation;
}
如果您的函数返回一个值(即,如果它不是
void
函数),则必须使用
return
来执行此操作。
InstalledPrice
也存在同样的问题

现在,当您使用这些函数时,您必须捕获返回值

    getdata (length, width, costpersqfoot);
    installation = InstalledPrice (length, width, costpersqfoot);
    price = totalprice (installation);
    printdata (length, width, price);

因此,在学习函数时,您肯定应该再看看如何使函数返回值。这是最基本的,但上面的代码中缺少了它。

编译器告诉您什么是错误的?这是一个开始猜测问题所在的好地方……尽管在这一点上,您可能不必猜测……)