### C++ output the highest number

So this program calculates bonus rates for multiple sales persons depending on how much they bring in. I then have to output the total bonus paid, the average bonus paid, and the largest bonus paid. I have everything working up till I have to output the largest bonus paid. I'm not sure how to go about this at all. I've been told to compare the input each time the for loop repeats, but I don't know how to do that.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142`` ``````#include #include #include using namespace std; int main() { int noPeople=0; char salesMember[50]; double salesIncome, bonusRate, bonusTotal=0, averageBonus; cout << "\t\t\tBonus Rates"; cout << "\n\nEnter number of sales people : "; cin >> noPeople; for (int x=1; x<=noPeople; x++) { cout << "\n\nEnter name of sales person : "; cin >> salesMember; cout << "Enter sales income : "; cin >> salesIncome; if (salesIncome <= 5000) {bonusRate = salesIncome * 0.000;} else if (salesIncome > 5000 && salesIncome <= 25000) {bonusRate = salesIncome * 0.15;} else if (salesIncome > 25000 && salesIncome <= 40000) {bonusRate = salesIncome * 0.20;} else {bonusRate = salesIncome * 0.50;} cout << "Bonus due : " << bonusRate; bonusTotal = bonusTotal + bonusRate; averageBonus = bonusTotal / noPeople; } cout << "\n\nTotal bonus amount paid : " << bonusTotal; cout << "\nAverage bonus amount paid : " << averageBonus; _getche(); return 0; }``````
 ``12345678`` ``````int max = array[0]; // start with max = first element for(int i = 1; i max) max = array[i];//highest value in array } ``````

int, double, whatever flavor you need same boilerplate.
Last edited on
Nevermind, sorted it.

Sorry mobotus, hadn't even noticed your reply when you I posted this. Thanks for the reply, was able to get it working in the end up. Thanks.
Last edited on
Topic archived. No new replies allowed.