Follow the included instructions to update previously written code for a functional casino program. Each step is laid out, so it should be easy to get the desired output. Examples of the outputs are also at the bottom of the instructions, so just make sure you get the same results. :)
University of Central Florida COP 3223 Into to Programming in C 4 Assignment 5 Due, Wednesday, November 11, 2020 for maximum 100 Thursday, November 12, 2020 for maximum 90 Friday, November 13, 2020 for maximum 80 Saturday, November 14, 2020 for maximum 70 Deliverables To complete this assignment you must submit your casino.c to Webcourses. Project description This project will require students to simulate a casino where players can select from a list of games they wish to play. Students will have to work through a series of programming implementations in order to complete the project. The project will include the use of primitive data type variables, arrays, user defined functions, and functions from the C library. Assignment Naming Convention It is highly recommended that for each iteration of the project students copy the previous assignment and rename it for additional functionality. The purpose of this implementation is two-fold. First, if there is a grading discrepancy, students have evidence that your source code worked as designed respective to what the grading rubric required. Second, the current implementation of Webcourses automatically renames a student’s assignment submission. The first submission would be “casino.c”, the second submission automatically gets renamed to “casino-1.c”, the third submission automatically gets renamed to “casino-2.c”, etc… and causes concern for students. Assignment Scope 1. Create a C source code file 2. Add functions to existing project 3. Use random function 4. Use decision making control flow 5. Use looping control flow 6. Use one dimensional array 7. Use two dimensional array 8. Use structs 9. Use formatted printing 10. Compile and run a file 11. Submit to Webcourses References Source code examples in Webcourses 1. dataTypes.c 2. functions.c 3. inputOutput.c 4. arrays.c 5. decisionMaking.c 6. looping.c 7. random.c 8. structures.c 9. typecasting.c Tasks Activity casino.c 1. Copy casino4.c to casion5.c 1. Add constants for game Scratch Offs as follows: a. BONUS as value of 20 2. Write the function declarations or prototypes for the follow functions a. cashOneDollar b. cashTwoDollar c. cashFiveDollar d. getBonus function playScratchOffs 3. Update function playScratchOffs to do the following a. Update the switch statement to do the following i. case ONE: set variable cash equal to function call cashOneDollar passing the struct OneDollar variable as an argument ii. case TWO: set variable cash equal to function call cashTwoDollar passing the struct TwoDollar variable as an argument iii. case FIVE: set variable cash equal to function call cashFiveDollar passing the struct FiveDollar variable as an argument function cashOneDollar 4. Write function cashOneDollar to do the following a. Return type int b. Parameter list struct OneDollar c. Declare the following constants i. SYMS with value 2 for number of bonus symbols ii. NUMS with value 5 for number of player numbers and prizes d. Declare the following variables i. cash, data type float for the player’s cash ii. n, data type integer for a looping variable iii. bonus, data type character set equal to function call getBonus passing constant ONE as an argument e. Write a printf statement to display the bonus symbol f. Write a for loop to loop five times i. Compare each of the player’s numbers to the winning number in the struct OneDollar parameter to determine if they are equal 1. If true, update the cash variable to add the associated prize in the struct OneDollar parameter to the current value of variable cash g. Write a for loop to loop two times i. Compare each of the player’s symbols to the bonus symbol (i.e. bonus) to determine if they are equal 1. If true, update the cash variable to add the bonus cash (i.e. BONUS) to the current value of variable cash h. Write a printf statement to inform the player their winnings for the scratch off ticket i. return cash explicitly type casted to data type int function cashTwoDollar 5. Write function cashTwoDollar to do the following a. Return type int b. Parameter list struct TwoDollar c. Declare the following constants i. WINS with value 2 for the number of winning numbers ii. SYMS with value 2 for number of bonus symbols iii. NUMS with value 10 for number of player numbers and prizes d. Declare the following variables i. cash, data type float for the player’s cash ii. w, data type integer for a looping variable iii. n, data type integer for a looping variable iv. bonus, data type character set equal to function call getBonus passing constant TWO as an argument e. Write a printf statement to display the bonus symbol f. Write a for loop to loop two times (i.e. number of winning numbers) i. Write a for loop to loop 10 times 1. Compare each of the player’s numbers to the winning numbers in the struct TwoDollar parameter to determine if they are equal a. If true, update the cash variable to add the associated prize in the struct TwoDollar parameter to the current value of variable cash g. Write a for loop to loop two times i. Compare each of the player’s symbols to the bonus symbol (i.e. bonus) to determine if they are equal 1. If true, update the cash variable to add the bonus cash (i.e. BONUS) to the current value of variable cash h. Write a printf statement to inform the player their winnings for the scratch off ticket i. return cash explicitly type casted to data type int function cashFiveDollar 6. Write function cashFiveDollar to do the following a. Return type int b. Parameter list struct FiveDollar c. Declare the following constants i. WINS with value 4 for the number of winning numbers ii. SYMS with value 4 for number of bonus symbols iii. NUMS with value 12 for number of player numbers and prizes d. Declare the following variables i. cash, data type float for the player’s cash ii. w, data type integer for a looping variable iii. n, data type integer for a looping variable iv. bonus, data type character set equal to function call getBonus passing constant FIVE as an argument e. Write a printf statement to display the bonus symbol f. Write a for loop to loop four times (i.e. number of winning numbers) i. Write a for loop to loop 12 times 1. Compare each of the player’s numbers to the winning numbers in the struct FiveDollar parameter to determine if they are equal a. If true, update the cash variable to add the associated prize in the struct FiveDollar parameter to the current value of variable cash g. Write a for loop to loop four times i. Compare each of the player’s symbols to the bonus symbol (i.e. bonus) to determine if they are equal 1. If true, update the cash variable to add the bonus cash (i.e. BONUS) to the current value of variable cash h. Write a printf statement to inform the player their winnings for the scratch off ticket i. return cash explicitly type casted to data type int function getBonus 7. Write function getBonus to do the following a. Return type character b. Parameter list data type integer (i.e. type) c. Declare the following constants i. Constant for the number of random symbols for OneDollar and TwoDollar scratch offs, data type integer set equal to the value 6 (i.e. ONE_TWO) ii. Constant for the number of random symbols for FiveDollar scratch off, data type integer set equal to the value 8 (i.e. FIVE_RAND) iii. Character array set equal to data set '$', '%', '&', '#', '@', '!', '^', '*' (i.e. SYMBOLS) d. Declare the following variables i. Data type character to store the bonus symbol (i.e. bonus) ii. Data type integer to store the random number selection (i.e. sym) e. Write an if statement to evaluate the parameter received (i.e. type) to determine if the scratch off type is ONE or TWO; if true i. Set variable sym equal to random number generation based six symbols ii. Write a switch statement to evaluate variable sym to select the bonus symbol from the SYMBOLS array and store the symbol in variable bonus f. else if statement to evaluate the parameter received (i.e. type) to determine if the scratch off type is FIVE; If true i. Set variable sym equal to random number generation based eight symbols ii. Write a switch statement to evaluate variable sym to select the bonus symbol from the SYMBOLS array and store the symbol in variable bonus g. return the bonus symbol (i.e. bonus) Casino executable Test Case 1 Test Case 1 passes Test Case 2 Test Case 2 passes Test Case 3 Test Case 3 passes Test Case 4 Test Case 4 passes Source compiles with no errors Source runs with no errors Source includes comments Perform the following test cases Test Cases Action Expected outcome Test Case 1 Run executable User clicks the
key User enters value 2 and clicks the key to select Scratch Offs When the executable runs and the user clicks at the Welcome screen The user enters the value 2 and clicks The output in the command prompt should look like Figure 1 Scratch Off function output Test Case 2 User enters value 1 to select a One Dollar scratch off ticket and clicks User enters a value for the number of tickets and clicks The player should be informed what their winnings are for the scratch off ticket. The screen displays similar output to Figure 3 OneDollar ticket Test Case 3 User enters value 2 to select a Two Dollar scratch off ticket and clicks User enters a value for the number of tickets and clicks The player should be informed what their winnings are for the scratch off ticket. The screen displays similar output to Figure 4 TwoDollar ticket Test Case 4 User enters value 5 to select a Five Dollar scratch off ticket and clicks User enters a value for the number of tickets and clicks The player should be informed what their winnings are for the scratch off ticket. The screen displays similar output to Figure 5 FiveDollar ticket Test Case 5 Player’s winnings should calculate correctly to reflect the prizes associated with player’s numbers matching the winning number(s) and the bonus symbol Figure 1 Scratch Off function output Figure 2 User prompts Figure 3 OneDollar ticket Figure 4 TwoDollar ticket Figure 5 FiveDollar ticket