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?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
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 <<endl;

	cout << "\n Please enter the amount of players in first place: ";
	cin >> 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)<<endl;


	if (Player ==2)
	cout <<"\n The first place winner receives " << DividedFirst(Pot,Player) <<endl;

	if (Player ==3)
	TooManyWinners();



	if (Player ==1,&&Player1>=2)
	cout << "\n The second place winners split the pot with; " << FiftyPercentSplit(Pot,Player1) <<endl;



	if (Player ==1,&&Player1==1,&&Player2>=1)
	cout << "\n The third place winner receives: " << TwentyPercent(Pot)<<endl;
return 0;
}
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.
also, please read this: http://www.cplusplus.com/forum/beginner/1/
closed account (o3hC5Di1)
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
closed account (o3hC5Di1)
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.