1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
// Im stuck here with a problem i get the errors that says
// Hw1a.cpp:(.text+0x41): undefined reference to `calcCommission(double)'
// Hw1a.cpp:(.text+0x65): undefined reference to `calcPay(double)'
// Hw1a.cpp:(.text+0x75): undefined reference to `displayPay()'
// collect2: error: ld returned 1 exit status
// this is the description of what I have to code and I have included my code
// below any help would be appreciated
// Include these 3 functions:
// getSalesAmt
// -This function prompts the user to enter a monthly sales amount.
// -The amount is read and assigned to a variable.
// -The value is then returned to main()
// calcCommission
// -This function calculates the commission based on the sales amount.
// -If a salesperson sells more than $50,000. per month, the commission is 2%
// of the sales amount.
// -If the sales are between $25,000 and $50,000., then the commission is 1.5%
// of the sales amount.
// -However, if the sales are less than $25,000., there is no commission.
// -The value is returned to main().
// calcPay
// -This function calculates the total monthly pay for a salesperson.
// -A salesperson gets a monthly salary of $2,500. plus a commission, if the person earned a commission.
// -The value is returned to main().
// displayPay
// -This function displays the total monthly pay for a salesperson.
// -Format the output to two decimal places, and with the amounts aligned as shown.
#include <iomanip>
#include <iostream>
double getSalesAmt();
double calcCommission(double sales);
double calcPay(double pay, double commission);
void displayPay(double sales, double commission, double pay, double totalPay);
int main()
{
double sales = getSalesAmt();
double commission = calcCommission(sales);
double pay = 2500;
double totalPay = calcPay(pay, commission);
displayPay(sales, commission, pay, totalPay);
return 0;
}
// getSalesAmt
// -This function prompts the user to enter a monthly sales amount.
// -The amount is read and assigned to a variable.
// -The value is then returned to main()
double getSalesAmt()
{
std::cout << "Enter the monthly sales amount: ";
double sales;
std::cin >> sales;
return sales;
}
// calcCommission
// -This function calculates the commission based on the sales amount.
// -If a salesperson sells more than $50,000. per month, the commission is 2%
// of the sales amount.
// -If the sales are between $25,000 and $50,000., then the commission is 1.5%
// of the sales amount.
// -However, if the sales are less than $25,000., there is no commission.
// -The value is returned to main().
double calcCommission(double sales)
{
double commission {};
if (sales > 50000) {
commission = sales * 0.02;
} else if (sales > 25000 && sales < 50000) {
commission = sales * 0.015;
} else {
commission = 0;
}
return commission;
}
// calcPay
// -This function calculates the total monthly pay for a salesperson.
// -A salesperson gets a monthly salary of $2,500. plus a commission, if the person earned a commission.
// -The value is returned to main().
double calcPay(double pay, double commission)
{
return pay + commission;
}
// displayPay
// -This function displays the total monthly pay for a salesperson.
// -Format the output to two decimal places, and with the amounts aligned as shown.
void displayPay(double sales, double commission, double pay, double totalPay)
{
std::cout << std::fixed << std::setprecision(2)
<< "Monthly Sales: $ " << sales
<< "\nCommission: $ " << commission
<< "\nBase Pay: $ " << pay
<< "\nTotal Pay: $ " << totalPay << '\n';
}
|