Include an array for 5 names and an array for the 5 corresponding sales which yo
ID: 3615527 • Letter: I
Question
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 step through the arrays and the old function to calculate the bonuses as below.
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. What is the algorithm, C++ code and sample data
and results.
Explanation / Answer
#inclue<conio.h> int bonuscal(int); void main() { int sales[5],bonus[5]; char name[5][20]; int v;for(v=0;v<5;v++) { cout<<"Enter the Name of First Person:"; cin>>name[v][]; cout<<"Enter the Sales of First Person:"; cin>>sales[v]; } for(v=0;v<5;v++) { int result=bonuscal(sales[v]); bonus[v]=result; }
cout<<"Name Bonus"; for(v=0;v<5;v++) { cout<<name[v][]; cout<<" "; cout<<bonus[v]; }
getch(); }
int bonuscal(int sal) { if((sal>0)&&(sal<3000)) return 0;
if((sal>3000)&&(sal<5000)) return 50; if((sal>5000)&&(sal<9999)) return 100;
if(sal>10000) return 250; } for(v=0;v<5;v++) { int result=bonuscal(sales[v]); bonus[v]=result; }
cout<<"Name Bonus"; for(v=0;v<5;v++) { cout<<name[v][]; cout<<" "; cout<<bonus[v]; }
getch(); }
int bonuscal(int sal) { if((sal>0)&&(sal<3000)) return 0;
if((sal>3000)&&(sal<5000)) return 50; if((sal>5000)&&(sal<9999)) return 100;
if(sal>10000) return 250; } if((sal>5000)&&(sal<9999)) return 100;
if(sal>10000) return 250; }