C++ LANGUAGE!!!! Create a program that simulates a slot machine. When the progra
ID: 3844425 • Letter: C
Question
C++ LANGUAGE!!!!
Create a program that simulates a slot machine. When the program runs it should do the following:
1. Asks the user to enter the amount of money he wants to enter into the slot machine.
2. Instead of displaying images, have the program display the name of the image. The program must randomly select a word from the following list:
Cherries, Oranges, Plums, Bells, Melons, Bars
To select a word, the program can generate a random number in the range of 0 to 5. If the number is 0, the selected word is Cherries, if the number is 1, then the selected word is Oranges, and so forth. The program should randomly select a word from the list 3 times and display all 3 of the words.
3. If none of the randomly selected words match, the program informs the user that he or she has won $0. If 2 of the words match, the program informs the user of the amount (2 times the amount entered) that he or she has won. If 3 of the words match, the program informs the user of the amount (3 times the amount entered) that he or she has won.
The program Runs Repeatedly until the user says NO.
You can define a function to generate the word in the list, another function to compare the three slots and display proper message. Then call those functions in the main function.
Explanation / Answer
code:
#include <iostream>
#include<map>
#include<stack>
#include<vector>
#include<algorithm>
#include <fstream>
#include<cstdlib>
using namespace std;
vector<string> li;
string getname()
{
int ind = rand() % 6;
return li[ind];
}
int main()
{
li.push_back("Cherries");
li.push_back("Oranges");
li.push_back("Plums");
li.push_back("Bells");
li.push_back("Melons");
li.push_back("Bars");
cout<<"enter the amount of money:"<<endl;
int mon;
cin>>mon;
cout<<getname()<<endl;
cout<<getname()<<endl;
cout<<getname()<<endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.