You are to enhance the original to include an array for 5 names and an array for
ID: 3615485 • Letter: Y
Question
You are to enhance the original to include an array for
5 names and an array for the 5 corresponding sales which
you are to input data from the keyboard using a looping
structure. Once the data is entered, the program is to
print out all 5 names and corresponding bonuses using an
additional function to step through the arrays and the
old function to calculate the bonus as
before. The old #3:
Scenario: "Flowers Forever" wants a program that the clerks
can use to calculate and display each salesperson's annual
bonus. The clerk will need to enter the salesperson's name
and sales. The application should calculate the bonus based
on the amount of sales as follows:
SALES BONUS
0-3000 0
3001-5000 50
5001-9999 100
10000+ 250
The program should echo input and output the calculated
bonus. Call a function to do the calculations. Do the
algorithms,C++ code and sample data and results.
Here is the algorithms and C++ code for the original:
Main Algorithm
Declare variables
INT total sales; bonus;
String name;
Prompt user;
Read name, total sales
Call function to calculate bonus
Print name, bonus
Algorithm for the function
Function calculate bonus (total sale)
IF (total sales is < 3001) return 0
IF (total sales is <5001) return 50
IF (total sales is <10000) return 100
ELSE return 250
C++ code
#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=calculatedbonus(sales);
cout << name << "'s bonus is $"<< bonus<<endl;
system("pause");
return 0;
}
int calculatedbonus(intsales)
{if (sales<3001)
return 0;
if (sales<5001)
return 50;
if (sales<10000)
return 100;
return 250;
}
Explanation / Answer
please rate - thanks #include #include using namespace std; int calculatedbonus(int); void calbonus(string[],int[],int); using namespace std; string name[5]; int sales[5]; int main () {int i; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.