使用函数的C++程序 我正在为我的C++类编写程序,我已经完成了程序。但它不会编译。我是编程新手,所以我真的不知道我做错了什么。如果有人能给我指出正确的方向。请帮帮我
提示说明: 编写一个C++程序,计算住宅和商业客户地毯和家具清洁的免费估价。程序将继续,直到到达文件末尾 对于住宅客户,指定并更新小沙发数量(每张50美元)、大沙发数量(每张80美元)、房间数量(每张70美元)和台阶数量(每张5美元),直到选择退出。账单是根据项目数量计算的。如果金额超过500美元,账单将享受10%的折扣。然后,客户可以从1、2、3或4分期付款中进行选择,或按0退出。基于分期付款选项,将账单增加到此处的最小代码,并计算每个分期付款金额 对于商业客户,请用户输入面积,然后按每平方英尺0.45计算账单 代码如下:使用函数的C++程序 我正在为我的C++类编写程序,我已经完成了程序。但它不会编译。我是编程新手,所以我真的不知道我做错了什么。如果有人能给我指出正确的方向。请帮帮我,c++,C++,提示说明: 编写一个C++程序,计算住宅和商业客户地毯和家具清洁的免费估价。程序将继续,直到到达文件末尾 对于住宅客户,指定并更新小沙发数量(每张50美元)、大沙发数量(每张80美元)、房间数量(每张70美元)和台阶数量(每张5美元),直到选择退出。账单是根据项目数量计算的。如果金额超过500美元,账单将享受10%的折扣。然后,客户可以从1、2、3或4分期付款中进行选择,或按0退出。基于分期付款选项,将账单增加到此处的最小代码,并计算每个分期付款金额 对于商业客户,请用户输入面积,然后按每平方英
请参阅以获取缩小问题范围的帮助,并编辑问题以包含错误消息。在包含错误消息时,请包含控制台中显示的确切错误消息。如果使用gcc/clang,请在编译字符串中添加-Wall-Wextra-pedantic-Wshadow选项,如果对其他编译器使用VS add/W3,检查如何启用警告,特别是对阴影变量发出警告。在没有警告的情况下编译代码之前,不要接受代码。您的错误是错误:“int exit”重新声明为不同类型的符号-有一个exit函数是C/C++的基础。代码中有一些编译错误。您的编译器将能够告诉您错误的内容和位置。我还建议您查看和。总之,使用全局变量实际上是所有隐藏变量问题的根源。在每个函数参数列表(该列表是函数变量的声明)中,重新声明全局声明的许多变量。这首先就破坏了将变量作为参数传递的目的。
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int exit = 0;
int smallcouches = 1;
int largecouches = 2;
int rooms = 3;
int steps = 4;
const float SMALL_COUCH = 50.0;
const float LARGE_COUCH = 80.0;
const float ROOMS = 70.0;
const float STEPS = 5.00;
const float PER_SQUARE_FOOT = 0.45f;
const float DISCOUNT_QUALIFIED = 500.0;
const float DISCOUNT = 0.10f;
const int ONE = 1;
const int TWO = 2;
const int THREE = 3;
const int FOUR = 4;
const float RATEONE = 0.0f;
const float RATETWO = 0.0535f;
const float RATETHREE = 0.055f;
const float RATEFOUR = 0.0575f;
float billAmount;
float ResidentialEstimate(float SMALL_COUCH, float LARGE_COUCH, float ROOMS, float STEPS, float DISCOUNT_QUALIFIED);
void GetResidentialItems(int& smallcouches, int& largecouches, int& rooms, int& steps);
void InstallmentPlan(float billAmount);
void BusinessEstimate(float PER_SQUARE_FOOT);
int main()
{
cout << fixed << showpoint << setprecision(2);
int customerType, residential_customer, business_customer;
char B, b, R, r;
residential_customer = R || r;
business_customer = B || b;
cout << "Enter customer type: R, r (Residential) or B, b (Business): ";
cin >> customerType; //Enter customer type
cout << endl;
while (cin) //While there is input to read
{
if (customerType == R || customerType == r) //if residential customer
{
ResidentialEstimate(SMALL_COUCH, LARGE_COUCH, ROOMS, STEPS, DISCOUNT_QUALIFIED); // call function ResidentialEstimate
InstallmentPlan(billAmount); // all function Installmentplan
}
else if (customerType == B || customerType == b) //else if business customer
{
BusinessEstimate(PER_SQUARE_FOOT); //call function BusinessEstimate
}
cout << "Enter customer type: R, r (Residential) or B, b (Business): ";
cin >> customerType; // Enter cutomer type
cout << endl;
}
return 0;
}
float ResidentialEstimate(float SMALL_COUCH, float LARGE_COUCH, float ROOMS, float STEPS, float DISCOUNT_QUALIFIED)
{
GetResidentialItems(smallcouches, largecouches, rooms, steps); //Call function GetResidentialItems to get items to clean
billAmount = (SMALL_COUCH + LARGE_COUCH + ROOMS + STEPS); //Calculate the bill amount
if (billAmount > 500) //if bill amount is more than 500 dollars
{
DISCOUNT_QUALIFIED = billAmount * 0.10f;
billAmount = billAmount - DISCOUNT_QUALIFIED; //Apply a discount of 10% to the bill amount
}
return billAmount; //return bill Amount
}
void GetResidentialItems(int& smallcouches, int& largecouches, int& rooms, int& steps)
{
int count;
int choice = smallcouches || largecouches || rooms || steps;
//Ask user to select an item to update or press 0 to exit
cout << "0. Exit, 1. Small Couches, 2. Large Couches, 3. Rooms, 4. Steps " << endl;
cout << "Enter one of the above choices: ";
cin >> choice;
cout << endl;
while (choice > 0) //while user hasn't pressed 0
{
choice = count;
cout << "Please enter the number of " << choice; //ask the user to enter a number from the item selected
cin >> count;
cout << endl;
//Show the current selections and numbers
cout << "Current selections: " << count << " Small Couches, " << count << " Large Couches, " << count << " Rooms, " << count << " Steps.";
//Ask user to select an item to update or press 0 to exit
choice = 0;
count = 0;
cout << "0. Exit, 1. Small Couches, 2. Large Couches, 3. Rooms, 4. Steps " << endl;
cout << "Enter one of the above choices: ";
cin >> choice;
cout << endl;
}
}
void InstallmentPlan(float billAmount)
{
int num;
int installment = 0;
int bill = 0;
//Ask user to select number of installments or 0 to exit
cout << "Please enter the desired number of instalments (1, 2, 3, or 4) or 0 to exit : ";
cin >> num;
cout << endl;
while (num > 0) //while user hasn't pressed 0
{
//calculate the installments
if (num == 1)
installment = billAmount;
else if (num == 2)
{
bill = billAmount * 0.0535f;
installment = bill / num;
}
else if (num == 3)
{
bill = billAmount * 0.055f;
installment = bill / num;
}
else if (num == 4)
{
bill = billAmount * 0.0575f;
installment = bill / num;
}
cout << "With " << num << " installment your bill of " << billAmount << " will be worth " << bill << "." << endl;
cout << "Each installment will be worth " << installment << endl;
//Ask user to select number of installments or 0 to exit
cout << "Please enter the desired number of instalments (1, 2, 3, or 4) or 0 to exit : ";
cin >> num;
cout << endl;
}
}
void BusinessEstimate(float squarefootage)
{
//Ask user for the square footage
cout << " Enter the approximate square footage: ";
cin >> squarefootage;
cout << endl;
//Calculate the bill amount
billAmount = squarefootage * PER_SQUARE_FOOT;
cout << "Your free Business Customer Estimate for " << squarefootage << "square footage = " << billAmount;
}