|
-
May 7th, 2010, 08:03 AM
#1
Roll a dice program.
I'm trying to make a dice program that will give a random number when user throws the dice. Every random number gets logged into a system that shows how many of every number has come. It's basic atm but my goal is to make it good.
It goes through the converter but it's not working properly.
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
srand((unsigned)time(0));
int first = 0;
int second = 0;
int third = 0;
int fourth = 0;
int fifth = 0;
int sixth = 0;
char Throw;
int i;
int randomnumber = 0;
do{
cout << "Write y if you want to throw, q quits\n";
cin >> Throw;
{
if(Throw == 'y')
for(int i=0; i<1; i++)
randomnumber = (rand()%6)+1;
}
{
if(randomnumber == '1')
first = first + 1;
else if(randomnumber == '2')
second = second + 1;
else if(randomnumber == '3')
third = third + 1;
else if(randomnumber == '4')
fourth = fourth + 1;
else if(randomnumber == '5')
fifth = fifth + 1;
else if(randomnumber == '6')
sixth = sixth + 1;
cout <<first<<"\n";
cout <<second<<"\n";
cout <<third<<"\n";
cout <<fourth<<"\n";
cout <<fifth<<"\n";
cout <<sixth<<"\n";
}
}
while(Throw != 'q');
return 0;
}
It prints: "
y
0
0
0
0
0
0
" indicating that none of the variables have changed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|