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

I need to create a C++ program; It must do the following: In the beginning of th

ID: 3649115 • Letter: I

Question

I need to create a C++ program;

It must do the following:

In the beginning of the program it should display the credit you have. It should ask you if you want to play. if
you type 'n' for no , then the program should terminate. If you type 'y' for yes, then the program rolls the two dice. If the user enters anything other than yes or no, the program should keep asking if they want to play.

It simulates the rolling of 2 dice. If the total of the two dice is 7 or 11, you win, otherwise, you lose. Your initial budget is 100 points. if you win + 20 points and if you lose - 20 points. Every time that the user roll's the dice, it must ask if they want to continue playing and also display their current budget.

Once your budget is 0, then the program should terminate and say that you do not have enough points to continue.

Note: use (rand() % 6 + 1) to simulate the dice. A standard dice (1-6) should be used.





Explanation / Answer

please rate - thanks

started with your code--message me before rating if any changes needed

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
    // declaring variables
    const int INCREMENT = 20;
    int credit;
    int die1, die2;
    int diceTotal;
    char yesno ='y';
    // ask the user if they want to play
      do
    {cout << "To play type 'y' or 'n' " << endl;
         cin >> yesno;
    }while(yesno!='y'&&yesno!='n');
    if(yesno=='y')
    {
     credit = 100;   
    // roll the dice (keep playing) as long as credit is greater than 10
    do
       {
        // intial credit is 100, roll the dice and sum both outcome
       
        die1 = (rand() % 6 + 1);
        die2 = (rand() % 6 + 1);
        diceTotal = die1 + die2;
        cout<<"you rolled a "<<diceTotal<<endl;
        // add 20 points when your total is either 7 or 11
        if (diceTotal == 7 || diceTotal == 11)
        {  
            credit = credit + 20;
        }
        else
        {
            credit = credit - 20;
        }

   
    // display your credit everytime you are asked if you want to play
    cout << "Your current credit is " << credit << endl<<endl;
    if(credit>0)
        do
           { cout << "To play type 'y' or 'n' " << endl;
                cin >> yesno;
            }while(yesno!='y'&&yesno!='n');
          
     }while (credit > 0&&yesno=='y');
}
     if(credit==0)
          {cout<<"sorry :( you do not have enough credit to continue you lost ";
           system("pause");
           }
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote