Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am making a sloting machine and it diplays 3 random words. If the words matche

ID: 3530166 • Letter: I

Question

I am making a sloting machine and it diplays 3 random words. If the words matches, the user wins that much amout of money. Then the system askes if the user want to play the game again. If the answer is yes, these steps are repeated. IF THE ANSWER IS NO, THE PROGRAM SHOULD DISPLAY THE TOTAL AMOUNT OF MONEY ENTERED INTO THE SLOT MACHINE AND THE TOTAL AMOUNT WON. But I dont know how to do the last part( if the answer is No). I think i need to use a running total. But i dont know where to put it. PLEASE HELP ME. this is my code #include #define cls system ("cls") #define pauseOutput system ("pause") // Pauses the output window using namespace std; // global constants const int CHERRIES = 1; const int ORANGES = 2; const int PLUMS = 3; const int BELLS = 4; const int MELONS = 5; const int BARS = 6; // Function prototypes void playGame(); void insertMoney(double &money); void spin(int &sym1, int &sym2, int &sym3); void showSpin(int sym1, int sym2, int sym3); void showsymbol(int symbol); int getMatches(int sym1, int sym2, int sym3); double calcWinnings(int matches, double money); void wantToPlayAgain(string &again); int main() { // Variable declaration / initialization time_t nowIsTheMoment; time(&nowIsTheMoment); cout << ctime(&nowIsTheMoment); // The again variable is used to determine whether the // user wants to continue playing the game. string again; // Start playing... do { //Pressing a key spins the machine. cout << "Press any key to spin..."; cin.get(); cout << endl; // Simulate the spin playGame(); // Does the user want to play again? wantToPlayAgain(again); cin.ignore(); } while (again == "Y"); pauseOutput; cls; return 0; } // The wantToPlayAgain function askes the user if he or she wants to play again // ans stores the input as "Y" or "N" in the reference parameter. void wantToPlayAgain(string &again) { cout << "Do you want to play again?"; cin >> again; while (again!= "Y" && again!= "N") { cout << "Enter either Y or N"; cin >> again; } } // The calcWinning function accepts the number of matches and the amount of //money inserted as arguments, and returns the amount of money won for this spin double calcWinnings(int matches, double money) { double winnings; winnings = (matches * money); return winnings; } // The insertMoney function prompts the user for the amount of money to insert // into the slot machine. The input is stored in the refrence parameter. void insertMoney(double &money) { cout << "How much money do you want to insert?"; cin >> money; cout << endl; } // The spin function stores three random values in the refrence parameter. // The CHERRIES global constant specifies the lowest value of the range // and the BARS global constant specifies the highest value of the range. void spin(int &sym1, int &sym2, int &sym3) { sym1 = CHERRIES + rand() % BARS; sym2 = CHERRIES + rand() % BARS; sym3 = CHERRIES + rand() % BARS; } // The showSpin function displays the symbol generated by the spin void showSpin(int sym1, int sym2, int sym3) { showsymbol(sym1); showsymbol(sym2); showsymbol(sym3); } // The showSymbol function displays a slot symbol as a word. void showsymbol(int symbol) { switch (symbol) { case CHERRIES: cout <<"Cherries" << endl; break; case ORANGES: cout << "Oranges" << endl; break; case PLUMS: cout << "Plums" << endl; break; case BELLS: cout << "Bells" << endl; break; case MELONS: cout << "Melons" << endl; break; case BARS: cout << "Bars" << endl; break; } } // The getMatches function accepts arguments for the three slot symbols and // returns the number of them that match. int getMatches(int sym1, int sym2, int sym3) { int matches; if (sym1 == sym2 && sym1 == sym3) { matches = 3; return matches; } else if (sym1 == sym2 || sym1 == sym3 || sym2 == sym3) { matches = 2; return matches; } else { matches = 0; return matches; } } // The playGame module plays one spin of the slot machine void playGame() { int sym1, sym2, sym3, matches; double money, winnings; double totalMoney = 0.0; // Function calls insertMoney(money); spin(sym1, sym2, sym3); showSpin(sym1, sym2, sym3); matches = getMatches(sym1, sym2, sym3); winnings = calcWinnings(matches, money); cout << " You won $" << winnings << endl << endl; }

Explanation / Answer

cant read the code.. post it in a readable format or upload it anywhere and share the link