Im creating a programme to find the lowest paid performer.
Below is the function that allows me to carry out this task.
How can I improve it to include multiple artists instead of just one lowest paid artist.
EXAMPLE: jane earns $10 and 10 other artists earn $20 so jane is the lowest. But suddenly, someone called tom enters and earns $10 too. so what do I do to improve the programme so that both tom and jane's name are recorded.
Standard cplusplus rules apply here, just give me some hints like what c++ concepts can I use etc and don't give me the answer.
Tried it.
This is my new code.
payArray[] is the total pay of the 10 staff
artists[] is a string array holding the name of the 10 artists
highestPay[] is a new array to store the pay of the new highest
highestArtists[] is a new array to store the names of the highest.
There are errors with the programme:
Result will be as follows:
Highest Pay Artist(s)
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
Initialise the highestPay and highestArtists with some odd looking value like 999 or 777 say. See what happens. This might help to see what you did wrong.
Sometimes, initialising with weird values can help with debugging.
A better thing to help with debugging, is a debugger :+) If using an IDE, there should be an easy to use GUI debugger built in. Have a watch-list of variables to keep an eye on, step through the code from a beak-point, 1 line at a time, see how your values change and deduce what went wrong.
With your code in your other post, you have a lot global's - that is bad. Keep the scope of your variables as tight as possible. Pass as arguments to functions whatever variables they need.