thanks


Thanks for your time.
Last edited on
Start by writing a programme that uses the rand function to generate a number between 1 and 6.
*stabs post deleters with a rusty sword and watches them bleed while their wounds become infected*
This thread was originally titled

HELP WITH DICE ROLLING.

Here is the original first post:

very confused please help!

I am trying to figur out how to write a program that simulates the rolling of two dice. Using rand() function roll the two dice one after the other. Use srand (time(0)); for setting the initial seed value. The sum of the two dice values in any through will be between 2 and 12. The probabilities for the various sums are: for 2 and for 12: 2.778%; for 3 and for 11: 5.556%; for 4 and for 10: 8.333%; for 5 and for 9: 11.111%; for 6 and for 8: 13.889; and for 7: 16.667%. Roll the two dice in your program 10,000 times, add the dice values in each throw and increment the appropriate sum value for the result. When all the 10,000 throws are completed, compute the probability for each of the sums (2 to 12). The program should output the results under three columns: the first one shows the sum, the second shows the theoretical probability and the third shows the observed provability.

Thanks for your time.



Here is a thread showing someone else completing this homework three years ago. This sort of thing would be funny if I didn't end up having to work with these people. http://www.daniweb.com/software-development/cpp/threads/136785
Last edited on
Disch wrote:
*stabs post deleters with a rusty sword and watches them bleed while their wounds become infected*


I remember when you called me immature. Just saying.
Last edited on
I remember that too. Those were the days. =D
Is Disch going to apologize for his terrible sense of humor, and prejudice? For this, and many other more interesting things stay tuned...

Die dead thread die. Die die die.
Man, I don't know what I'm going to do. The suspense is killing me!
wtf... why is this thread here? its not asking anyhting...
/*
* main.cpp
*
* Created on: 25/10/2011
* Author: Yazamut4
*/

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

class A
{

public:
int getx();
void setx( int num );
void powerup();


int x ;
};

int A::getx()
{
return x ;
}

void A::setx( int num)
{
x = num ;
}

void A::powerup()
{
x = x * x ;
}

class B:A
{
public:
int getx();
void setx( int num );

};

int B::getx()
{
return x ;
}

void B::setx( int num)
{
x = num ;
}

class C:A
{
public:
int getx();
void setx( int num);
void doSomehting();
};


int C::getx()
{
return x;
}

void C::setx( int num)
{
x = num + 100 ;
}

void C::doSomehting()
{
x -= 200 ;
}

int main()
{
int i = 1 ;
char line[25] = "aaaaaaaaaaa" ;

ofstream myfile ;
myfile.open("example.txt");

ifstream incomingfile ;
incomingfile.open("example2.txt");

cout << "trial" << endl ;

if ( incomingfile.is_open() )
{
cout << incomingfile ;
cout << incomingfile.eof() << endl ;
while ( ( incomingfile.eof() == 0 ) && ( i < 20 ) )
{
cout << incomingfile.getline(line,25) << "fsdfsdfs" << endl;

cout << line << endl ;
myfile << i << ". " <<line << endl;
i++ ;
}
cout << "\nEnd of file.\n";
}
myfile << "Writing this to a file.\n";
myfile << "This is the second line.\n" ;
myfile.close();
incomingfile.close();
/*int num = 0 ;
A first ;
B second ;
C third ;
cout << "number? " ;
cin >> num ;
cout << num << endl ;
first.setx(num);
first.powerup();
cout << first.getx() << endl ;

second.setx( first.getx() );
cout << "second number is: " << second.getx() << endl ;

third.setx( num ) ;
cout << "Third is : " << third.getx() << endl ;
third.doSomehting();
cout << "Third is : " << third.getx() << endl ;
*/
return 0 ;
}
Topic archived. No new replies allowed.