Question
using c++ I started creating a new empty bag of balls (the bolded one) . The ADT was provided. Below is the instructions and the
using c++
I started creating a new empty bag of balls (the bolded one) . The ADT was provided. Below is the instructions and the code i started working on
1. Modify the appropriate typedef .this was done in he .h file 2. Create a bag of 100 chars. This bag will hold balls. Well use R for red ball, B for blue. 3. Fill the bag with 100 balls: red ball, blue ball, red ball, blue ball, etc. (50 red and 50 blue total) 4. Ask the user for Number of trials: . (e.g., numTrials) 5. Do numTrials times: a. Sample 10 balls. How many are red? Add this to a totRed10Count. b. Sample 100 balls. How many are red? Add this to a totRed100Count. c. Sample 1000 balls. How many are red? Add this to a totRed1000Count. 6. In a nice report, display the average percentage of red balls grabbed from the bag for each sample size.
Here is the code that I started working on
// FILE: rlprobsim.cxx // Demonstration program for the 3rd version of the bag (bag3.h and bag3.cxx). // This is a the same as the demonstration program for bag1, // except that we no longer need to check whether the bag reaches its // capacity.
#include
// PROTOTYPES for functions used by this demonstration program: void get_ages(bag& ages); // Postcondition: The user has been prompted to type in the ages of family // members. These ages have been read and placed in the ages bag, stopping // when the user types a negative number.
void check_ages(bag& ages); // Postcondition: The user has been prompted to type in the ages of family // members once again. Each age is removed from the ages bag when it is typed, // stopping when the bag is empty.
int main( ) { bag balls; intnumtrials; get _balls(balls); Cout <<" How many trials would you like?" << endl; cin >> numtrials;
for (int i =0; i < numtrials; i++); gets_balls (bag& balls); return EXIT_SUCCESS; }
Void get_bags(bags& ages); { cout<< " How many balls did you want to get?" <
void get_ages(bag& ages) { int user_input; // An age from the user's family
cout << "Type the ages in your family. "; cout << "Type a negative number when you are done:" << endl; cin >> user_input; while (user_input >= 0) { ages.insert(user_input); cin >> user_input; } }
void check_ages(bag& ages) { int user_input; // An age from the user's family
cout << "Type those ages again. Press return after each age:" << endl; while (ages.size( ) > 0) { cin >> user_input; if (ages.erase_one(user_input)) cout << "Yes, I've got that age and have removed it." << endl; else cout << "No, that age does not occur!" << endl; } } */
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started