我对 c++ 中的许多概念都比较陌生。这是学校的工作。现在我正在使用
if(smartPhones >= 6000)
commission = (smartPhones - 6000) * .25;
else(commission = 0);
if(serviceContracts >= 3500)
commission1 = (serviceContracts - 3500) * .10;
else(commission1 = 0);
if(accessories >= 2000)
commission2 = (accessories - 2000) * .05;
else(commission2 = 0);
if(maintenance >= 500)
commission3 = (maintenance - 500) * .07;
else(commission3 = 0);
计算手机销售佣金。如果某人销售超过 6000 部手机,他们将获得每部超过 6000 部手机的 25% 的佣金,超过 3500 份服务合同他们将获得每份超过 3500 部合同的 10% 的佣金。如果他们没有达到这些限制,他们将不会收到任何佣金对于那个类别。
我需要不断调用并使用单个函数来计算所有 4 个标准(智能手机、服务合同、配件和维护合同)的佣金。我将如何正确地做到这一点,我需要在函数中包含什么?我可以在函数内部使用 If/Else 语句吗?
double calcComm(double sales, double base, double percent)
{
}
计算佣金后,我需要使用 void 函数来调用并在列和行中显示排列的数据量。类似的东西
void display()
{
double ID, totalCommission, smartPhones, serviceContracts, accessories, maintenance, commission, commission1, commission2, commission3, base, total;
cout << "Commission Statement for Salesman #: "<< ID << endl;
cout << left << "Product and Sales Amount " << endl;
cout << left << "Smart Phones: " << smartPhones << endl;
cout << left << "Service Contracts: "<< serviceContracts << endl;
cout << left << "Accessories: " << accessories << endl;
cout << left << "Maintenance Contracts: " << maintenance << endl;
cout << left << "Commission for all Products" << endl;
cout << left << "Smart Phones: " << commission << endl;
cout << left << "Service Contracts: " << commission1 << endl;
cout << left << "Accessories: " << commission2 << endl;
cout << left << "Maintenance Contracts: " << commission3 << endl;
cout << left << "Total Commission " << totalCommission << endl;
cout << left <<"Base Pay " << base << endl;
cout << left << "Total Due " << total << endl;
}