Information
Here is a sample output from the program:
You start with 100 points. Each play costs 10 points. There are 3 slots, each contains 5 different values. If you get 2 of the same, you win 15 points. If you get 3 of the same, you win 30 points. Here we go! 4 4 4 BIG WINNER! You get 30 points!! You now have 120 points. Play again? (1=yes,0=no) 1 1 4 4 You win 15 points. You now have 125 points. Play again? (1=yes,0=no) 1 2 4 4 You win 15 points. You now have 130 points. Play again? (1=yes,0=no) 1 2 2 2 BIG WINNER! You get 30 points!! You now have 150 points. Play again? (1=yes,0=no) 1 2 2 5 You win 15 points. You now have 155 points. Play again? (1=yes,0=no) 1 1 4 1 You win 15 points. You now have 160 points. Play again? (1=yes,0=no) 0
The program continues to run until the user types in 0 (zero) or runs out of points. You should use a do...while loop again.
The name of the file should be slots1.c and the command to compile it will look like this:
gcc -O -Werror -Wall -Wextra -ansi -pedantic slots1.c PRNG.c -o slots1
Approximate number of lines of code: 30.
Notes
using the correct names for the input and output files. You can make your own input files, as well.slots1 < input.txt > myoutput.txt
Pay attention to the redirection operators. Here are the input files: input1.txt and input2.txtslots1 < input1.txt > myoutput.txt slots1 < input2.txt >> myoutput.txt
For those that would like an additional challenge: