What am I doing wrong? (code problem)

I need some simple help. I have created this program code that I will show. Here is the problem. The first time through, in the middle of the program it asks for a new number. When you enter the number, it stays that number through the loops. How do I get it to pause and ask the question (iRoll) and read in the new answer each time through the loop? Also, I set it to shut the loop off if you type in "n" at the end; however, it runs the program one more time before shutting down.

I need some help with this as it is probably a simple error, but I'm just a beginner.


*********************************************************************************************
* Name: Date Assigned: 10-16-08
* Course: CSE 1233 Date Due: 10-23-08
*
* File Name: psk29lab5.h
*
* Program Objective: To develop a game using random numbers that represent 1-6 on die and to
* have different values for different combinations.
*********************************************************************************************/

#include<stdio.h>
#include<stdlib.h>


int main()

{
char cYesNo = '\0';
char cRoll = '\0';
int iRoll = 0;
int iRandom1 = 0;
int iRandom2 = 0;
int iRandom3 = 0;
int iRandom4 = 0;
int iRandom5 = 0;
int iRandom6 = 0;
int iScore = 0;
int iScore2 = 0;
int iTotal1 = 0;
int iTotal2 = 0;
srand(time());

system("clear");
printf("Welcome to a game of Quispe. You and the computer will each roll two dice\n");
printf("to determine the winner. There is an option for a re-roll of one die if\n");
printf("the user so desires. A one and a two on the die will result in a Quispe.");
printf("\n1000 points will be awarded for a Quispe. If doubles are rolled, the points\n");
printf("will be added by multiplying the number on the die by 110. If you have two\n");
printf("different numbers, the first die will be multipled by ten and then the second\n");
printf("die number will be added to it. The highest point total wins the game.");

do
{

iRandom1 = rand() % 6 + 1;
iRandom2 = rand() % 6 + 1;
iRandom3 = rand() % 6 + 1;
iRandom4 = rand() % 6 + 1;
iRandom5 = rand() % 6 + 1;
iRandom6 = rand() % 6 + 1;

printf("\n\nComputer Die 1: %d", iRandom1);
printf("\nComputer Die 2: %d", iRandom2);

if(iRandom1 + iRandom2 == 3)
{
iScore = 1000;
printf("\nComputer score is %d\n\n", iScore);
}
else if(iRandom1 == iRandom2)
{
iScore = iRandom1 * 110;
printf("\nComputer score is %d\n\n", iScore);
}
else
{
iScore = iRandom1 * 10 + iRandom2;
printf("\nComputer score is %d\n\n", iScore);
}

printf("\nUser Die 1: %d", iRandom3);
printf("\nUser Die 2: %d", iRandom4);

if(iRandom3 + iRandom4 == 3)
{
iScore2 = 1000;
printf("\nUser score is %d\n\n", iScore2);
}
else if(iRandom3 == iRandom4)
{
iScore2 = iRandom3 * 110;
printf("\nUser score is %d\n\n", iScore2);
}
else
{
iScore2 = iRandom3 * 10 + iRandom4;
printf("\nUser score is %d\n\n", iScore2);
}

printf("Type 1 to reroll die 1, 2 to reroll die 2, or 3 to stay as it is: ");
scanf("%d", &iRoll);

if(iRoll == 1)
{
printf("\nUser Die 1: %d", iRandom5);
printf("\nUser Die 2: %d", iRandom4);

if(iRandom5 + iRandom4 == 3)
{
iScore2 = 1000;
printf("\nUser score is %d\n\n", iScore2);
}
else if(iRandom5 == iRandom4)
{
iScore2 = iRandom5 * 110;
printf("\nUser score is %d\n\n", iScore2);
}
else
{
iScore2 = iRandom5 * 10 + iRandom4;
printf("\nUser score is %d\n\n", iScore2);
}
}
else if(iRoll == 2)
{
printf("\nUser Die 1: %d", iRandom3);
printf("\nUser Die 2: %d", iRandom6);

if(iRandom3 + iRandom6 == 3)
{
iScore2 = 1000;
printf("\nUser score is %d\n\n", iScore2);
}
else if(iRandom3 == iRandom6)
{
iScore2 = iRandom3 * 110;
printf("\nUser score is %d\n\n", iScore2);
}
else
{
iScore2 = iRandom3 * 10 + iRandom6;
printf("\nUser score is %d\n\n", iScore2);
}
}
else
{
printf("\nUser Die 1: %d", iRandom3);
printf("\nUser Die 2: %d", iRandom4);

if(iRandom3 + iRandom4 == 3)
{
iScore2 = 1000;
printf("\nUser score is %d\n\n", iScore2);
}
else if(iRandom3 == iRandom4)
{
iScore2 = iRandom3 * 110;
printf("\nUser score is %d\n\n", iScore2);
}
else
{
iScore2 = iRandom3 * 10 + iRandom4;
printf("\nUser score is %d\n\n", iScore2);
}
}
if(iScore > iScore2)
{
printf("\nThe computer won this round.\n");
}
else
{
printf("\nYou have won this round. Congratulations!\n");
}
iTotal1 += iScore;
iTotal2 += iScore2;

printf("\nThe computer overall score is %d", iTotal1);
printf("\nYour overall score is %d", iTotal2);

if(iTotal1 > iTotal2)
{
printf("\n\nThe computer is winning.\n");
}
else if(iTotal1 < iTotal2)
{
printf("\n\nYou are winning. Keep it up!\n");
}
else
{
printf("\n\nA tie? Are you kidding?\n");
}

printf("\n\nDo you want to continue? (y or n): ");
scanf("%c ", &cYesNo);

}while
(cYesNo != 'n');
return 0;
}





Post your topic only once and only in one section please...also there is a delete button next to your post if you want to delete the post.
I attempted to re-create what you just made. There are a few silly mistakes though.
You are repeating some functions. Even if you enter '3' as your option (leave die as they are), you still say the dice rolls and scores again. It seems unnecessary.
And a few more that I have forgotten.

Here's my attempt. The rolling bit works, but when its for the overall score, it stuffs up and always says it is a TIE. If you enter 'N' at the end, it will turn into an infinite loop and keep doing it. Maybe if you could fix this it might work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include <iostream>
#include <ctime>
using namespace std;

int main()
{
    char endGame;
    int rollAgain;
    int diceThrow1;
    int diceThrow2;
    int computerThrow1;
    int computerThrow2;
    int diceScorePlayer;
    int diceScoreComputer;
    int overallScorePlayer = 0;
    int overallScoreComputer = 0;
    
    do
    {
                   srand(time(0));
                   diceThrow1 = rand() % 6 + 1;
                   diceThrow2 = rand() % 6 + 1;
                   computerThrow1 = rand() % 6 + 1;
                   computerThrow2 = rand() % 6 + 1;
                   
                   cout << "\nComputer Dice Throw 1: " << computerThrow1;
                   cout << "\nComputer Dice Throw 2: " << computerThrow2;
                   
                   if (computerThrow1 + computerThrow2 == 3)
                   {
                                      diceScoreComputer = 1000;
                                      cout << "\nComputer Score is " << diceScoreComputer;
                   }
                   else if (computerThrow1 == computerThrow2)
                   {
                                      diceScoreComputer = computerThrow1 * 110;
                                      cout << "\nComputer Score is " << diceScoreComputer;
                   }
                   else
                   {
                                      diceScoreComputer = computerThrow1 * 10 + computerThrow2;
                                      cout << "\nComputer Score is " << diceScoreComputer;
                   }
                   
                   cout << "\nUser Dice Throw 1: " << diceThrow1;
                   cout << "\nUser Dice Throw 2: " << diceThrow2 << endl;
                   
                   if (diceThrow1 + diceThrow2 == 3)
                   {
                                      diceScorePlayer = 1000;
                                      cout << "\nUser Score is " << diceScorePlayer;
                   }
                   else if (diceThrow1 == diceThrow2)
                   {
                                      diceScorePlayer = diceThrow1 * 110;
                                      cout << "\nUser Score is " << diceScorePlayer;
                   }
                   else
                   {
                                      diceScorePlayer = diceThrow1 * 10 + diceThrow2;
                                      cout << "User Score is " << diceScorePlayer;
                   }
                   
                   cout << "\nType '1' to reroll dice 1, '2' to reroll dice 2 or '3' to leave it.";
                   cin >> rollAgain;
                   
                   if (rollAgain == 1)
                   {
                                 diceThrow1 = rand() % 6 + 1;
                                 
                                 cout << "\nUser Dice Throw 1: " << diceThrow1;
                                 cout << "\nUser Dice Throw 2: " << diceThrow2;
                                 
                                 if (diceThrow1 + diceThrow2 == 3)
                                 {
                                                diceScorePlayer = 1000;
                                                cout << "\nUser Score is " << diceScorePlayer;
                                 }
                                 else if (diceThrow1 == diceThrow2)
                                 {
                                                diceScorePlayer = diceThrow1 * 110;
                                                cout << "\nUser Score is " << diceScorePlayer;
                                 }
                                 else
                                 {
                                                diceScorePlayer = diceThrow1 * 10 + diceThrow2;
                                                cout << "\nUser Score is " << diceScorePlayer;
                                 }
                   }
                   else if (rollAgain == 2)
                   {
                                 diceThrow2 = rand() % 6 + 1;
                           
                                 cout << "\nUser Dice Throw 1: " << diceThrow1;
                                 cout << "\nUser Dice Throw 2: " << diceThrow2;
                                 
                                 if (diceThrow1 + diceThrow2 == 3)
                                 {
                                                diceScorePlayer = 1000;
                                                cout << "\nUser Score is " << diceScorePlayer;
                                 }
                                 else if (diceThrow1 == diceThrow2)
                                 {
                                                diceScorePlayer = diceThrow1 * 110;
                                                cout << "\nUser Score is " << diceScorePlayer;
                                 }
                                 else
                                 {
                                                diceScorePlayer = diceThrow1 * 10 + diceThrow2;
                                                cout << "\nUser Score is " << diceScorePlayer;
                                 }
                   }
                   else
                   {
                                 cout << "\nDie left as it was thrown.";
                   }
                   
                   if (diceScorePlayer < diceScoreComputer)
                   {
                                    cout << "\nThe computer has won this round.";
                   }
                   else if (diceScorePlayer > diceScoreComputer)
                   {
                                    cout << "\nCongratulations! You have won this round!";
                   }
                   else
                   {
                                    cout << "\nWOW! You both had the same scores! TIE!";
                   }
                   
                   overallScorePlayer + diceScorePlayer;;
                   overallScoreComputer + diceScoreComputer;
                   
                   if (overallScorePlayer < overallScoreComputer)
                   {
                                    cout << "\nThe computer is currently leading the competition.";
                   }
                   else if (overallScorePlayer > overallScoreComputer)
                   {
                                    cout << "\nYou are leading the competition. Keep it up!";
                   }
                   else if (overallScorePlayer == overallScoreComputer)
                   {
                                    cout << "\nAmazing, a tie! You better be kidding.";
                   }
    
                   cout << "Do you wish to continue? ('Y' or 'N')";
                   cin >> endGame;
                   } while (endGame != 'N' || endGame != 'n');
                   if (endGame == 'N' || endGame == 'n')
                   {
                   cout << "Congratulations. You have left the game with " << overallScorePlayer << " points." << endl;
                   system("PAUSE");
                   return(0);
                   }
    }
this problem was also posted in the beginner's forum.
It has been resolved
if you look at lines 131 and 132, the overall score is not stored in a variable, but calculated and then lost.
Topic archived. No new replies allowed.