I need some guidance on what to do next. I wrote the program as much as I could.
If you see a better way to fix my code, please let me know.
I want to finish my program, but I don't know what to do. Below are the instructions given to me, and how the Output must be displayed.
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.
/* ===== Output ========================================================
Enter a monthly sales amount: $
Monthly Sales: $
Commission: $
Base Pay: $
Total Pay: $
Do it again (Y or N)?
*/
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
|
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int getSalesAmt();
void displayPay(int salesAmt);
float calcCommission(float commission);
int main()
{
int salesAmt;
char answer = 'Y';
salesAmt = getSalesAmt();
while (toupper(answer) == 'Y')
{
displayPay(salesAmt);
cout << "Do it again (Y or N)? ";
cin >> answer;
if (toupper(answer) == 'Y')
{
getSalesAmt();//doesn't display newly entered monthly sales.
}
}
return 0;
}
int getSalesAmt()
{
int salesAmt;
cout << "Enter a monthly sales amount: ";
cin >> salesAmt;
return salesAmt;
}
float calcCommission(float commission, int salesAmt)
{
float commission;
if (salesAmt >= 50000)
{
commission = .02;
}
if (salesAmt >= 25000 & salesAmt <= 50000)
{
commission = .015;
}
else
{
commission = 0;
}
return commission;
}
/*
float calcPay()
{
}
*/
void displayPay(int salesAmt)
{
cout << "\nMonthly Sales: $" << salesAmt << endl;
cout << "\nCommission: $" << fixed << setprecision(1) << showpoint << endl;
cout << "\nBase Pay: $" << fixed << setprecision(1) << showpoint << endl;
cout << "\nTotal Pay: $" << fixed << setprecision(1) << showpoint << endl << endl;
}
|