Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C programming language make a program that takes bets on horse races. There will be four types of bets described below. The horse race

Using C programming language make a program that takes bets on horse races. There will be four types of bets described below. The horse race result is generated by a function called ReadySetgo that simply scrambles the horses into random order as a pseudo/simulated horse race and that tells you the race results.
We assume four horses run in a race (though you want to write it so it would be fairly easy to change teh number of horses), and we assume the horses are named by numbers 1-4. Advanced students if you feel adventurous you can (but are not obligated to) give the horses more creative names and make the number of horses running in the race programmable rather than fixed to four.
Lets say the horses are initially in the order 1234. If you call Readysetgo to randomly shuffle them (thats our pseudo-race) we might get a race result of 2143 for example, which means: horse #2 came in first, horses #1 came in second, horse #4 came in third and horse # 3 came in fourth.
The user starts out with 200 dollars. Betting costs are as follows:
Exacta bet costs 15 dollars, you win 150 if you win by picking both the first place horse and picking the second place horse exactly right
Exacta Box bet costing 10 dollars, you win 100 if you win by picking both the first place and second place horse and they can come in any order.
Trifecta bet costs 20 dollars, you win 250 if you win by picking the first place horse and picking the second place horse and picking the third place horse exactly right.
Trifecta Box bet costs 18 dollars, you win 180 if you win by picking the first place and second place and third place horse and they can come in any order.
Advanced students can (but are not obligated to) make this bet cost programmable, ie some students allow the user to decide how much they want to bet on the race, and some even let the user borrow money and get more in debt if they keep on losing and run out their 200 dollars.
We need our program to allow the user to place any of the four types of bets. The user is given a USD (US dollars) cash balance of 200 dollars for betting. The menu options allow the user to place any of the four bets, run the race, see the result, see what their cash balance is, and exit the program. Advanced students if you wanted to (but are not obligated to) you could save a history of the bets they placed so they could also ask for their betting history.
There are two easy ways to implement the user interface for this, one is going to be with a simple text based menu, and one is going to be with a simple string/command-line based menu. A text menu is where you give the user a choice of options and tell them for example: enter 1 to place an exactabet, enter 2 to place an exactabox bet, etc. ie:
Welcome to Horse Betting!
Please select from the following options 1-6
Place an exact bet
Place an exactabox bet
Place a trifectabet
Please a trifectabox bet
See your USD balance
Exit
etc
They then choose the option they want and then you ask them what horses they pick as the winners, get their pick, run the race, see if they won, etc.
A string based menu is a slightly different input style, where the input is more of a command-line driven sentence that gets parsed into components in the program to determine what they want, for example, if the user inputs the command line sentence
> exacta 12
the program will read that in, divide that up into the components and figure out that they are placing an exacta bet with horse 1 and 2 as the picks. This involves splitting the input up - if you think of the input as a sentence you will want to chop it up into words.
YOU SHOULD IMPLEMENT THIS WITH THE STRING BASED MENU USING THE STRING SPLIT.
Example Input:
EXACTA 13
EXACTA 13 means that we are betting that the winner and second place will be exactly in that order (ie; the bet is betting that horse #1 will come in first place, and horse #3 will come in second place)
EXACTABOX 14
EXACTABOX 14 means that we are betting that the winning two horses will be 1 and 4 in any order. So if the race comes in as 4123, you still win the bet since horse number 1 and 4 are still in the top two places.
And also two more types of bet
TRIFECTA 132
TRIFECTA 132 means that we are betting that the winners will be exactly in that order (ie; the bet is saying that horse #1 will come in first place/win, horse #3 will come in second place/place, and that horse #2 will come into third place/show.
TRIFECTABOX 142
TRIFECTABOX 142 means that we are betting that the winning three horses will be 1,4, and 2 in any order. So if the race comes in as 1243, you still win the bet because horse number 1,2, and 4 are in the top three places.
Grading
(25 points)
Get the input from the user.
White a string based menu that uses the string split to get the bet from the user as one sentence. For example,
You enter your bets at the prompts
bet> exacta 21
b

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago