$23.99
A slot machine is a gambling device that the user inserts money into and then pulls a lever or push a button. The slot machine then displays a set of random images. If one image matches, the user wins the amount of money he or she bets. If two or more of the images match, the user wins an amount of money that the slot machine dispenses back to the user.
Create a program that simulates a slot machine. When the program runs, it should do the following:
· Read in the initial amount of money a user wants to enter into the slot.
· Ask the user to enter the amount of money he or she wants to bet. The amount of money must be a multiple of $10. The minimum is $10 and maximum is the amount of money the user currently has.
· Display a menu for the user to select a word from the following list:
1. Cherrie
2. Orange
3. Apple
4. Peach
5. Melon
6. Pear
· Ask the user to select one word by entering the number between 1 and 6
· Randomly select a word from the above list three times and display all three of the words
· If none of the randomly selected words match, the program will inform the user that he or she has won $0. If one of the words match, the program will inform the user that he or she has won one time of the amount entered. If two of the words match, the program will inform the user that he or she has won two times the amount entered. If three of the words match, the program will inform the user that he or she has won three times the amount entered.
· The program will ask whether the user wants to play again. If so, these steps are repeated. If not, the program displays the total amount of money entered into the slot machine and the total amount won.
Please write a program that displays the following information and write to a file named output.txt:
· The amount of money the user bets
· The word the user selects
· The three words the slot machine randomly selects
· The amount of money the user wins if any
· Whether or not the user wants to continue play
· The amount of money the user wins or lose if he or she quits
· Greeting messages
Note: your program must be user-friendly and intuitive. This is a part of your grade. In other words, even if your program does everything the problem statement states, your grade may be reduced because of difficulty to it.
Input
This program requires that you read in the following data values:
Ø The amount of money a user owns initially. It is read from a input file named input.txt
Ø Whether or not a user wants to play
Ø The amount of money he wants to bet each time
Ø The word a user selects
You will use interactive I/O and File I/O in this program. All of the input must be validated. For example, if a user enters 7 for his selection of word, then your program must display an error message and ask the user to re-enter a number between 1 and 6.
Output
All the output must be printed on the console and also written to a file on the disk. The output file must be named as output.txt.
Test case output: (green texts are user input)
Welcome to Guanyu Tian's
Slot Machine!
You inserted $200 into the slot machine!
You currently have $200,
you can bet
the multiple of $10.
If you
enter 1, you will
bet $10
If you
enter 2, you will bet $20, etc.
Please
enter how much do
you want to
bet this time: -2
Sorry,
you don't $-20 now. You can only bet less than the amount of money you have.
You currently have $200,
you can bet
the multiple of $10.
If you
enter 1, you will
bet $10
If you
enter 2, you will
bet $20, etc.
Please
enter how much do
you want to
bet this time: 1000
Sorry, you don't $10000 now. You can only bet less than the amount of money you have.
You currently have $200, you can bet the multiple of $10.
If you enter 1, you will bet $10
If you enter 2, you will bet $20, etc.
Please enter how much do you want to bet this time: 4
Your currently bet: $40
Please select one of the fruit by entering a number between 1 and 6:
1 - Cherry
2 - Orange
3 - Apple
4 - Peach
5 - Melon
6 - Pear
Please enter your selection: -2
Invalid selection. you must enter a number between 1 and 6 inclusive.
1 - Cherry
2 - Orange
3 - Apple
4 - Peach
5 - Melon
6 - Pear
Please enter your selection: -5
Invalid selection. you must enter a number between 1 and 6 inclusive.
1 - Cherry
2 - Orange
3 - Apple
4 - Peach
5 - Melon
6 - Pear
Please enter your selection: 8
Invalid selection. you must enter a number between 1 and 6 inclusive.
1 - Cherry
2 - Orange
3 - Apple
4 - Peach
5 - Melon
6 - Pear
Please enter your selection: 4
Result: Cherry Melon Orange
None of the randomly selected words matched your selection. You won $0
Do you want to continue playing (y/Y) or quit (n/N):g
Invaild choice!!! Please enter y or Y to play, n or N to quit: Do you want to
continue playing (y/Y) or quit (n/N):h
Invaild choice!!! Please enter y or Y to play, n or N to quit: Do you want to
continue playing (y/Y) or quit (n/N):R
Invaild choice!!! Please enter y or Y to play, n or N to quit: Do you want to
continue playing (y/Y) or quit (n/N):y
You currently have $160, you can bet the multiple of $10.
If you enter 1, you will bet $10
If you enter 2, you will bet $20, etc.
Please enter how much do you want to bet this time: 7
Your currently bet: $70
Please select one of the fruit by entering a number between 1 and 6:
1 - Cherry
2 - Orange
3 - Apple
4 - Peach
5 - Melon
6 - Pear
Please enter your selection: 5
Result: Peach Pear Apple
None of the randomly selected words matched your selection. You won $0
Do you want to continue playing (y/Y) or quit (n/N):Y
You currently have $90, you can bet the multiple of $10.
If you enter 1, you will bet $10
If you enter 2, you will bet $20, etc.
Please enter how much do you want to bet this time: 4
Your currently bet: $40
Please select one of the fruit by entering a number between 1 and 6:
1 - Cherry
2 - Orange
3 - Apple
4 - Peach
5 - Melon
6 - Pear
Please enter your selection: 6
Result: Melon Peach Apple
None of the randomly selected words matched your selection. You won $0
Do you want to continue playing (y/Y) or quit (n/N):N
You currently have $50. You have lost $150
Thank you for choose Guanyu Tian's Slot Machine! Good bye...
Miscellaneous
Be sure to read and understand the sections in the Course Syllabus handout on general project requirements. Also be sure to study the style, documentation and formatting guidelines discussed in the Programming Style Guidelines handout and in the lecture.
What File To Turn In and How to Turn In Your Work using Blackboard
You must turn in your Java program source file which must be named as follows:
Use this format: HW4_SlotMachineSimulation.java.