# Can someone programme for me?

• November 7th, 2013, 03:49 PM
chemical_dog
Can someone programme for me?
Problem Description
Helen likes to have the occasional flutter (bet) on the horses. She likes to be able to see
what her winnings would be for various scenarios. You are to design and develop a bet
winnings calculation program for her.

The program should ask the user for the following information:
• The total stake (the amount bet)
• The name of the horse
• Whether the bet is for an outright win or it is an each-way bet
• The betting odds in this way:
o Enter the betting odds (X/Y)…
 Enter X > 11
 Enter Y > 10
o Odds are 11/10.
• The number of runners in the race
• The finishing position of the horse

There are some rules to consider when calculating the winnings:
• If there are 7 horses or less in the race, then only the first 2 places are considered for
each-way bets
• If there are between 8 and 20 horses in the race, then the first 3 places are
considered for each-way bets
• If there are more than 20, then the first 4 places are considered for each-way bets
Winnings are calculated as follows:
• Outright win bets: the winnings are the original stake + the odds multiplied by the
original stake
o Example: 5 euro win bet placed on a horse at 11/10
o = €5 + ( €5 * 11/10 ) = €10.50
• Each-way bets: Half of the stake is a standard outright win bet and is calculated as
above, e.g. a €5 each-way bet involves 2 x €5. The other half is applied in the
following way:
o If there are 2 places considered (see rules above), then half the odds are used
if the horse finishes first or second
o If there are 3 places considered, then a third of the odds are used if the horse
finishes first, second or third
o If there are 4 places considered, then a quarter of the odds are used if the
horse finishes first, second, third or fourth
o If the horses places, but does not win, then half the original stake is returned
along with the winnings
o If the horse wins, then the entire stake (i.e. both the win and place portions)
are returned along with the winnings

• You must format your output, e.g. winnings of zero as €0.00 or 5.3 as €5.30.
• The horse’s name must be output in all capitals.
• You must display 1st, 2nd, 3rd, 4th, etc. 10 would be 10th, 20 would be 20th, etc.
• You should include basic validation for all input – see the last example for checking
the finishing position; should also check that bet type is ‘E’ or ‘W’; should ensure that
the finishing position is not greater than the number of horses in the race.

Everything I have so far:
Code java:

```import java.util.Scanner;   public class part1 {   public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); double stake; String horsesName; double outrightWinOrEachWay; double outrightWin; double eachWay; double OddsX; double OddsY; double totalOdds; double eachWayOdds; double runners; double finishingPosition; double winnings; double win; double place;       System.out.println("Please enter your stake:"); while (! keyboard.hasNextDouble() ) { keyboard.nextLine(); System.out.print("Please try again "); } stake = keyboard.nextFloat();     horsesName = keyboard.nextLine();   while ( horsesName.isEmpty() )   { System.out.print("What is your horses name?"); horsesName = keyboard.nextLine(); }   System.out.println("Enter the betting odds (x/y)"); System.out.println("X=");   while (! keyboard.hasNextDouble() ) { keyboard.nextLine(); System.out.print("Please try again "); } OddsX = keyboard.nextFloat();   System.out.println("Y="); while (! keyboard.hasNextDouble() ) { keyboard.nextLine(); System.out.print("Please try again "); } OddsY = keyboard.nextFloat();   totalOdds = (OddsX/OddsY);   System.out.println("How many runners are in the race?"); while (! keyboard.hasNextDouble() ) { keyboard.nextLine(); System.out.print("Please try again "); } runners = keyboard.nextFloat();   System.out.println("What is your finishing position?"); while (! keyboard.hasNextDouble() ) { keyboard.nextLine(); System.out.print("Please try again "); } finishingPosition = keyboard.nextFloat();   System.out.println("Is your bet a:"); System.out.println("(1) Outright Win"); System.out.println("(2) Eachway"); while (! keyboard.hasNextDouble() ) { keyboard.nextLine(); System.out.print("Please try again "); } outrightWinOrEachWay = keyboard.nextFloat();   if (outrightWinOrEachWay == 1) { if (finishingPosition == 1) { winnings = stake + (totalOdds * stake); System.out.println(horsesName + " finished 1st out of " + runners + " runners"); System.out.println("You have won \u20ac" + winnings); }   if (finishingPosition > 1) { System.out.println("Sorry you didn't win"); } }   if (outrightWinOrEachWay == 2) { if (runners < 7) {   eachWayOdds = (totalOdds/2);   if (finishingPosition == 1) { win = stake + (totalOdds * stake); place = stake + (eachWayOdds * stake); winnings = win + place; System.out.println(horsesName + " finished 1st out of " + runners + " runners"); System.out.println("You have won \u20ac" + winnings); }   if (finishingPosition ==2) { winnings = stake + (eachWayOdds * stake); System.out.println(horsesName + " finished 1st out of " + runners + " runners"); System.out.println("You have won \u20ac" + winnings); }   if (finishingPosition> 2){ System.out.println("Sorry you didn't win"); }   if (runners > 8) {   } }     }   } }```
• November 7th, 2013, 03:56 PM
Norm
Re: Can someone programme for me?
[code=java]
[/code]
to get highlighting and preserve formatting.

• November 7th, 2013, 03:58 PM
chemical_dog
Re: Can someone programme for me?
No.
• November 7th, 2013, 04:05 PM
Norm
Re: Can someone programme for me?
Quote:

Originally Posted by chemical_dog
No.

Good luck.
• November 7th, 2013, 04:09 PM
chemical_dog
Re: Can someone programme for me?
Did I do good?
• November 7th, 2013, 04:11 PM
Norm
Re: Can someone programme for me?
• November 7th, 2013, 04:14 PM
chemical_dog
Re: Can someone programme for me?
Quote:

Originally Posted by Norm

No problems, I was just wondering if somebody would be ever so kind as to finish it for me? I would be forever in there debt.
• November 7th, 2013, 04:17 PM
Norm
Re: Can someone programme for me?
Sounds like you want to hire a programmer. I'll move this thread to another section.

Most sections here are for students trying to learn java programming.
• November 7th, 2013, 04:21 PM
chemical_dog
Re: Can someone programme for me?
Thank you Mr. Norm.

--- Update ---

I wasn't planning on paying anyone for it though, just thought they'd do it out of the kindness of there hearts...
• November 7th, 2013, 04:37 PM
copeg
Re: Can someone programme for me?
To be blunt: this smells like homework, in which case it smells like academic dishonesty. Don't let someone else take take away the fun of doing it (as well as take away your education). If you're stuck, then post again with a specific question regarding where you are stuck. I am locking this thread.