### Money Result Calculator help :/

So, I'm trying to figure out the amount of money a Golf player receives according to their position. However, often we have many players who end up in the same positioning.
For example, sometimes there are 2 people in 1st place, 2 people in 2nd place, and 3 people in 3rd place. In this situation, we'd give 80% of the money split to first, and 20% of the money split to second, excluding 3rd place. Situation where it's 5 people in 1st, 2 people in 2nd, and 3 in 3rd, therefore making the pot be split within the first 5 people. The Pot itself is altered every day, as every player chips in every new game.

Here's my code so far, and It doesn't work :( Help?

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495`` ``````#include using namespace std; int FiftyPercent(int a) { return a*.50; } int FiftyPercentSplit(int A, int B) { return A*.50/B; } int ThirtyPercent(int b) { return b*.30; } int TwentyPercent(int c) { return c*.20; } int DividedFirst(int e, int f) //This regards when the first place has 2 in 1st, and 1 or more in second. { return e*.80/f; } int DivideSecond (int E, int F)//This regards when the first place has 2 in 1st, and 1 or more in second. { return E*.20/F; } void TooManyWinners() { cout << "There are too many winners in first place, therefore the pot is split between them."; } int main () { double Pot,Player,Player1,Player2; cout << "Please enter the total pot: "; cin >> Pot; cout << "The total pot is: " << Pot <> Player; cout << "\n Please enter the amount of players in second place: "; cin >> Player1; cout << "\n Please enter the amount of players in third place: "; cin >> Player2; if (Player==1) cout << "\n The first place winner receives " << FiftyPercent(Pot)<=2) cout << "\n The second place winners split the pot with; " << FiftyPercentSplit(Pot,Player1) <=1) cout << "\n The third place winner receives: " << TwentyPercent(Pot)<
Last edited on
Code Tags
Please use code tags, if you want any help.
To insert code tags, hit edit in the post above this one, and on the right hand side you should see something like:
< >
click it and insert all your code in between it.
Hi there,

This is actually a maths question as far as I can see.
You need a "distribution algorithm" (not sure if that's the correct term) for assigning the prizemoney to the players.

It may be worth asking this question in the lounge - but make sure to highlight that what you need is the mathematical formula to calculate this.

In addition to what Script Coder said, adding code tags is as easy as: [code] your code here [/code]

Sorry I couldn't be of more help.

All the best,
NwN
Script Coder, Thank you for the heads up, I appreciate you taking the time to do so.

NwN, I understand what you mean, and am glad that math is the issue, as it's no surprise, my math skills aren't the greatest.

Other than the math part, is there anything else I could do with the code, any other functions I should use? What do you guys think?

Thank you.
Cheers.
Last edited on
Hi there,

It's a simple enough program that this should suffice.
You could, if you want put the logic asking the user for information in a separate function, as well as the logic displaying the info to the user, but for a small structured program like this I would say that's not vital.

All the best,
NwN
Topic archived. No new replies allowed.