Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C Programming language, write a code for a program that takes bets on horse races.There will be four types of bets described below. The

Using C Programming language, write a code for 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 and we assume the horses are named by numbers 1-4.
Lets say the horses are initially in the order 1234. If you call Readysetgo to randomly shuffle them 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.
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.
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.
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.
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.
YOU SHOULD IMPLEMENT THIS WITH THE STRING BASED MENU USING THE STRING SPLIT.
Get the input from the user.
Write a string based menu that uses the string split to get the bet from the user as one sentence.
Write the following four function
Exacta. Takes as input a two element array (for Python use list) with their bets, a four element array of the winning sequence, and returns true if they win the exacta
Exactabox.Takes as input a two element array (for Python use list) with their bets, a four element array of the winning sequence, and returns true if they win the exacta box
Trifecta.Takes as input a three element array (for Python use list) with their bets, a four element array of the winning sequence, and returns true if they win the trifecta
Trifectabox. Takes as input a three element array (for Python use list) with their bets, a four element array of the winning sequence, and returns true if they win the trifecta bo
Display the Cheat, each time they want to bet you need to run the race anew and show the new results of the race to the user before they make their bets, that way user can cheat and win if they want. if they know the winning sequence was 1324, they could make an exact bet of 13 and they should win the money.
Every time they bet, you are going to first run the race anew and then show them the cheat
The Cheat: 1324
To show me your program works you need eight examples if you use the cheat,Please demonstrate: Win an exacta, Lose an exacta, Win an exacta box, Lose an exacta box, Win a trifecta, Lose a trifecta, Win a trifecta box, Lose a trifecta box. Make sure to turn in the source code, and the output with the 8 examples
Use the class (case of C programming) I give you called Readysetgo which will run a race with four horses and randomly generate for you the winning sequence. program will Take the user's input, then run the race using this method, figure out if they won or not using the four functions described above.
Keep track of your money as USD and assume you start out with 200 dollars. When you make a bet, deduct the cost of the bet from your USD, and when you win a bet, add the win amount to your USD. Be able to print out your balance as a menu or command option.
Put your logic into a loop to keep placing bets and running races and see your balance as you go. Implement an Exit string command to leave the betting game and a Balance string command to your menu which shows their current balance.

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_2

Step: 3

blur-text-image_3

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions