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.");
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.
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.