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?
#include <iostream>
usingnamespace 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;
}
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/
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]
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.