In: Computer Science
  | 
----------------------------------------------------------------------------------------------------------------------------------------------
scratchOffs fucntion:
int playScratchOffs(int cash)
{
printf("Let's play scratch off tickets!\n");
return cash;
}
----------------------------------------------------------------------------------------------------------------------------------------------
My Code So Far:
//define struct OneDollar
struct OneDollar {
int winNumber;
int numbers [5];
float prizes [5];
char bonus [2];
int oneSO;
} OneDollar;
//define struc TwoDollar
struct TwoDollar {
int winNumbers [2];
int numbers [10];
float prizes [10];
char bounus [2];
int twoSO;
} TwoDollar;
// define struc FiveDollar
struct FiveDollar {
int winNumbers [4];
int numbers [12];
float prizes [12];
char bonus [4];
int fiveSO;
} FiveDollar;
//function declaration for a. createScratchOffOne
int createScratchOffOne ();
//function declaration for b. displayScratchOffOne
int displayScratchOffOne ();
//function declaration for c. createScratchOffTwo
int createScratchOffTwo ();
//function declaration for d. displayScratchOffTwo
int displayScratchOffTwo ();
//function declaration for e. createScratchOffFive
int createScratchOffFive ();
//function declaration for f. displayScratchOffFive
int displayScratchOffFive ();
int playScratchOffs(int cash)
{
//declare integer variables
int type;
int count;
int c;
//variable declaration with structure
int main () {
struct OneDollar (oneSO);
struct TwoDollar (twoSO);
struct FiveDollar (fiveSO);
}
printf("Let's play scratch off tickets!\n");
printf("Players can select from OneDollar, TwoDollar and FiveDollar
tickets\n");
printf("Prizes are based on the ticket selected\n");
clearScreen();
printf ("Which type of scratch off would you like\n");
printf ("(1 = One Dollar, 2 = Two Dollar, 5 = Five
Dollar)?\n");
printf ("How many scratch offs would you like?\n");
return cash;
}
Here we just needed to follow line by line instructions provided. Here is the complete code WITH APPROPRIATE COMMENTS EXPLAINING IT.
#include<stdio.h>
int playScratchOffs(int cash){
    // an integer variable to store the type of scratch off (i
    int type;
    int count;
    // loop control
    int c;
    // Declare a variable of data type struct OneDollar (i.e. oneSO)
    struct OneDollar oneSO;
    // Declare a variable of data type struct TwoDollar (i.e. twoSO)
    struct TwoDollar twoSO;
    // Declare a variable of data type struct FiveDollar (i.e. fiveSO)
    struct FiveDollar fiveSO;
    printf("Let's play scratch off tickets!\n");
    // Write a printf statement to prompt the user for the type of scratch off, similar to Figure 2 User prompts
    printf("Enter type of scratch off: ");
    // Save the user input in variable type    // 
    scanf("%d",&type);
    // Write a printf statement to prompt the user for the number of scratch off, similar to Figure 2 User prompts
    printf("Enter for the number of scratch off: ");
    // Save the user input in variable count
    scanf("%d",&count);
    // Write a for loop to loop for the number of scratch offs
    for(c=0;c<count;c++){
        // Write a switch statement evaluating the scratch off type
        switch (type)
        {
            // Case ONE
        case 1:
            oneSO = createScratchOffOne(oneSO);
            displayScratchOffOne(oneSO);
            break;
        // Case TWO
        case 2:
            twoSO = createScratchOffTwo(twoSO);
            displayScratchOffTwo(twoSO);
            break;
        // Case five
        case 5:
            fiveSO = createScratchOffFive(fiveSO);
            displayScratchOffFive(fiveSO);
            break;
        
        }
    }
// RETURN CASH
    return cash;
}