macavenger
Registered
Ok, I have three questions here. Hopefully someone will be able to answer at least one of them 
1)How can I get a program (in C++) to accept input from the keyboard without having to press enter? I would like to make a menu where the user can just type their selection number to choose from the menu, without having to press return or enter afterwards.
2)The random number generator on my computer is being weird. I have written a program for my CS201 class that rolls two dice 36000 times each, and at each roll calculates the sum of the two dice. after it is done, it displays how many times each possible sum was rolled. However, for some reason, the number rolled on the first die is always odd, and the number rolled on the second die is always even, or vice versa. This of course totally messes up the output, as the sum is always odd. When I run the program on another computer, it works fine. Anyone know what I can do about this?
My code (I do of course have the necesarry #include statements, hopefully the code won't be too mangled):
3)For some reason, the Project Builder debugger has started ignoring breakpoints. It worked fine the first few times I used it, but lately I can put in a breakpoint on every line, and it will just blithely run through the program, never stopping once. I have no clue what I did to cause this. Anyone know how to fix it?
Any help that you can provide would be greatly appreciated. Thanks!
1)How can I get a program (in C++) to accept input from the keyboard without having to press enter? I would like to make a menu where the user can just type their selection number to choose from the menu, without having to press return or enter afterwards.
2)The random number generator on my computer is being weird. I have written a program for my CS201 class that rolls two dice 36000 times each, and at each roll calculates the sum of the two dice. after it is done, it displays how many times each possible sum was rolled. However, for some reason, the number rolled on the first die is always odd, and the number rolled on the second die is always even, or vice versa. This of course totally messes up the output, as the sum is always odd. When I run the program on another computer, it works fine. Anyone know what I can do about this?
My code (I do of course have the necesarry #include statements, hopefully the code won't be too mangled):
Code:
int main () {
srand(time(0));
int sum[13]={0}, die_1=0, die_2=0;
for(int roll=1; roll<=36000;roll++)
{
die_1=1+rand()%6;
die_2=1+rand()%6;
sum[die_1+die_2]++;
}
cout<< setw(5)<<"Sum"<< setw(10)<<"Rolls"<< endl;
for(int i=2; i<=12; i++)
{
cout<< setw(5)<< i;
cout<< setw(10)<< sum[i]<< endl;
}
return 0;
}
3)For some reason, the Project Builder debugger has started ignoring breakpoints. It worked fine the first few times I used it, but lately I can put in a breakpoint on every line, and it will just blithely run through the program, never stopping once. I have no clue what I did to cause this. Anyone know how to fix it?
Any help that you can provide would be greatly appreciated. Thanks!