Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Question - 02
- #include <bits.stdc++.h>
- using namespace std;
- // --- ( a )---
- class Dice {
- private:
- double ara[7];
- public:
- Dice() {
- for( int i = 0; i < 7; i++ ) {
- ara[i] = 0;
- }
- }
- void roll() {
- srand(time(0));
- int d = 1 + rand() % 6;
- ara[d] += 1.00;
- }
- class Experiment {
- public:
- bool isFair() {
- double tot = 0;
- for( int i = 1; i < 7; i++ ) {
- tot += ara[i];
- }
- double percentage[7], minn = 101.00, maxx = 0.00;
- for( int i = 1; i < 7; i++ ) {
- percentage[i] = ( ara[i] / tot ) * 100;
- if( minn > percentage[i] ) {
- minn = percentage[i];
- }
- if( maxx < percentage[i] ) {
- maxx = percentage[i];
- }
- }
- if( maxx - minn >= 10.00 ) {
- return false;
- }
- return true;
- }
- }
- class Program {
- private:
- int numberOfRolls;
- public:
- Program( int rolls ) {
- numberOfRolls = rolls;
- }
- int getRolls() {
- return numberOfRolls;
- }
- void setRoll( int roll ) {
- numberOfRolls = rolls;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement