I'm having a problem adding up the values of the dice rolls in a while loop. The program will only store the last value so how would I get it to store multiples values? Here is my program thus far.
#include <iostream>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main()
{
int die_1=0, die_2=0, total_score1, total_score2, player1score;
char enter;
cout<<"Welcome to the dice game. The rules are as follows: \n";
cout<<"1. Roll the two dice and add up the total. \n";
cout<<"2. If you roll a 7 or an 11, your turn is over and it is now the other players turn. \n";
cout<<"3. If the other player rolls a 7 or an 11, then the scores are tallied and the player with the highest score wins.\n";
cout<<"Enter the letter s and press enter to roll.\n";
cin>>enter;
srand(time(0));
if((enter = 's') || (enter = 'S'))
{
do
{
die_1 = (rand() % 6) +1;
die_2 = (rand() % 6) +1;
total_score1 = die_1 + die_2;
player1score = total_score1;
cout<<total_score1<<endl;
}while((total_score1 != 7) && (total_score1 != 11));
cout<<"Player score is: "<<player1score<<endl;
}
return 0;
}
Anyone know what operators or equation I should use to accomplish this?