need help on this c++ program no shorts cut follow all direction thank you
Write a program that can report the bonuses all employees in the department will receive in the current quarter. You must use parallel arrays to load employee names and bonus information, process the information, and produce the required report. You must not prompt the user for the information.You can make up the employee names. You must use the random number generator to generate the bonus amounts. The source file must be called bonuses.cpp and should include the functions specified below.
The steps for writing the functions have been provided. You must follow the steps to complete the functions.
– The main function. In the main function, define an array of 12 employee names (you must initialize the array with a list of employee names that you make up) and an array of 12 doubles for storing the employee bonuses. You must use a named constant for the size declarator, 12, of the arrays. These are so called parallel arrays. That is, the employee name at certain subscript in the first array is related to the bonus at the same subscript in the second array. Set up the random number generator by seeding it with current time. Then call the function getBonuses and pass the array of bonuses and its size (the named constant) to load the bonus amounts into the array of bonuses. At last, call the function reportBonuses and pass the arrays and their size information (the named constant) to report the bonuses.
– A function named getBonuses that will receive two parameters: an array of bonuses, and the number of bonuses. The function should use the random number generator to set the bonus for each employee in the array of bonuses. The bonuses should be in hundreds and in the range from 100 to 2500. For examples, 1200 or 1300, but not something like 1281.
– A function named getTotalBonus that will receive two parameters: an array of bonuses, and the number of bonuses. The function should find the total amount of bonuses from the given array of bonuses and return the total amount.
– A function named getLargestBonus that will receive two parameters: an array of bonuses, and the number of bonuses. The function should find the largest bonus from the given array of bonuses and return the largest bonus amount.
– A function named reportBonuses that will receive four parameters: an array of employee names who may receive bonuses, the number of employee names, an array of bonuses, and the number of bonuses. The function should call getTotalBonus to determine the total of the bonuses given to the employees and getLargestBonus to determine the largest bonus that has been given to the employees. The function should report the bonuses using the following format:
Report of Bonuses
Employee Name Bonus
————————————-
Henry Kim 1200.00
Michelle Rice 1300.00
Total of bonuses: 2500.00
Largest bonus: 1300.00
Expert Answer
C++ Code |
#include<iostream>
#include<string> #include<ctime> #include<cstdlib> #include<iomanip> #include<cmath> using namespace std; /** * Function to assign bonus value */ void getBonuses(double bonusArray[], int size) { for(int i = 0; i < size; i++) { bonusArray[i] = 100 + ( rand() % ( 2500 – 100 + 1) ); // random generating bonus amount int rem = fmod(bonusArray[i], 100.0); // getting the remainder by dviding by 100 bonusArray[i] = bonusArray[i] – rem; // subtracting the remainder from bonus to get multiple of 100 } } /** * Function to calculate and return the total bonus amount */ double getTotalBonuses(double bonusArray[], int size) { double sum = 0; for(int i = 0; i<size; i++) { sum += bonusArray[i]; } return sum; } /* * Function to get largest bonus amount from bonus array */ double getLargestBonus(double bonusArray[], int size) { double largest = bonusArray[0]; for(int i = 0; i < size; i++) { if(largest < bonusArray[i]) largest = bonusArray[i]; } return largest; } /** * Function to print the bonus stats */ void reportBonuses(string employees[], int numEmployee, double bonusArray[], int size) { double totalBonus = getTotalBonuses(bonusArray, size); double largestBonus = getLargestBonus(bonusArray, size); cout<<“Report of BonusesnEmployee Name Bonusn————————————-n”; for(int i = 0; i < numEmployee; i++) { cout<<setw(14)<<employees[i]<<setw(13)<<“$ “<<bonusArray[i]<<endl; } cout<<“nnTotal of bonuses:”<<setw(10)<<“$”<<totalBonus<<endl; cout<<“Largest bonus:”<<setw(10)<<“$”<<largestBonus<<endl<<endl; system(“PAUSE”); } // main function int main() { srand(time(NULL)); const int SIZE = 12; string employees[] = { “John Bubbles”, “Henry Kim”, “John Marshal”, “Michael Dutt”, “Amit Rana”, “Aparajita M”, “Albert Thomas”, “Jolly Anders.”, “Henry Anders.”, “Vipin Balana”, “Elizabeth”, “Sarah K” }; double bonusArray[SIZE]; getBonuses(bonusArray, SIZE); reportBonuses(employees, SIZE, bonusArray, SIZE); } |
OUTPUT