خرید بک لینک

Vote count: 0

I need cherries, oranges, plumes, bells, melons, or bars to be randomly picked in the case statements and in a way I can then display what was chosen so I can compare them, but I'm not sure how.

For example, I was hoping when I printed slot1, slot2, and slot3, I would get the names of which case statement inside each of the three switches were chosen.

Not their numbers.

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;

int main()
{
    int slot1;
    int slot2;
    int slot3;

    double won;
    double money;

    string cherries;
    string oranges;
    string plums;
    string bells;
    string melons;
    string bars;
    string doAgain;

    do
    {
        cout << "We are going to be playing a slot machine game today." << endl;
        cout << "Please enter the amount of money you'd like to insert into the slot machine." << endl;
        cin >> money;
        cout << "You put in $" << money << endl;


        srand(time(0));

        slot1=rand()%6+1;
        slot2=rand()%6+1;
        slot3=rand()%6+1;

        switch (slot1)
        {
        case 1:
            cout << cherries << endl;
        case 2:
            cout << oranges << endl;
            break;
        case 3:
            cout << plums << endl;
            break;
        case 4:
            cout << bells << endl;
            break;
        case 5:
            cout << melons << endl;
            break;
        case 6:
            cout << bars << endl;
        }

        switch (slot2)
        {
        case 1:
            cout << melons << endl;
            break;
        case 2:
            cout << bells << endl;
            break;
        case 3:
            cout << bars << endl;
            break;
        case 4:
            cout << plums << endl;
            break;
        case 5:
            cout << oranges << endl;
            break;
        case 6:
            cout << cherries << endl;

        }

        switch (slot3)
        {
        case 1:
            cout << bars << endl;
            break;
        case 2:
            cout << plums << endl;
            break;
        case 3:
            cout << melons << endl;
            break;
        case 4:
            cout << bells << endl;
            break;
        case 5:
            cout << oranges << endl;
            break;
        case 6:
            cout << cherries << endl;

        }

       cout << "The numbers you got were " << slot1 << ", " << slot2 << ", " << slot3 << endl;





        cout << "Would you like to play again?" << endl;
        cin >> doAgain;

        if(doAgain!= "yes")
        {
            cout << "The total amount of money you put in the slot machine is" << money << endl;
            cout << "The total amount of money you won is $" << won << endl;
        }

    }
    while(doAgain=="yes");



    retu 0;
}

    enter code here

asked 18 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 15 تير 1395 ساعت: 6:07

صفحه بندی