Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming Project #4 This is an extension of program project #3. You are to en

ID: 3615739 • Letter: P

Question

Programming Project #4

This is an extension of program project #3.

You are to enhance the original to include an array for 5 names andan array
for the 5 corresponding sales which you are to input data from thekeyboard
using a looping structure. Once the data is entered, the program isto
print out all 5 names and corresponding bonuses using an additionalfunction
to step through the arrays and the old function to calculate thebonus as
before.

Scenario: "Flowers Forever" wants a program that the clerks can useto
calculate and display each salesperson's annual bonus. The clerkwill need
to enter the salesperson's name and sales. The application shouldcalculate
the bonus based on the amount of sales as follows:

SALES         BONUS

0-3000          0
3001-5000      50
5001-9999     100
10000+        250

I have my old C++ program:
The program should echo input and output the calculated bonus. Calla function
to do the calculations. Turn in PDL and C++ code.

This is my old program, project #3:
#include <iostream>
#include <string>
int calcbonus(int);
using namespace std;
char name [50];
int sales,bonus;
int main () {
    cout << "Enter the salesperson's name.";
    cin.getline (name, 50);
    cout << "Enter the person's sales amount.";
    cin >> sales;
    bonus=calcbonus(sales);
    cout << name << "'s bonus is $"<< bonus<<endl;
    system("pause");   
return 0;
}
int calcbonus(int sales)
{if (sales<3001)
        return 0;
if (sales<5001)
       return 50;
if (sales<10000)
    return 100;
    return 250;
}
If someone could convert my old program into the new one, thatwould be greatly appreciated.
I will rate high!

Explanation / Answer

This should work, you can mess with the output if you want. I made some minor changes to the previous code to make iteasier to use.
#include <iostream> #include <string>
using namespace std; string name; int sales, bonus; // -- establish size of arrays const int MAX = 5; //-- New arrays string names[MAX]; int bonuses[MAX];
// -- Function Prototypes int calcbonus(int); void outputArrays(string names[], int bonuses[]);
// -- int main () {    // -- get names and sales, calc bonus and storeinfo in Arrays    for (int i = 0; i < MAX; i++)    {    if (i == 0)    cout << "Enter thesalesperson's name: ";    else    cout << "Enter thenext salesperson's name: ";    getline (cin, name);    names[i] = name;    cout << "Enter the person'ssales amount: ";    cin >> sales;    bonus=calcbonus(sales);    bonuses[i] = bonus;    cout << name << "'sbonus is $" << bonus << endl;    cin.ignore(100,' ');    }    outputArrays(names, bonuses);    system("pause"); return 0; }
// -- Calculate Bonus Function int calcbonus(int sales) {    if (sales<3001)    return 0;    if (sales<5001)    return 50;    if (sales<10000)    return 100;    return 250; }
// -- Output Array information for Names and Bonuses void outputArrays(string names[], int bonuses[]) {    for(int i = 0; i < MAX; i++)    {    cout << "Name: " <<names[i] << " Bonus: "<< bonuses[i] <<endl;    } }