Question

C++ Jerry’s Appliance has a special promotion for its week long Anniversary Sale. After Customers have...

C++

Jerry’s Appliance has a special promotion for its week long Anniversary Sale. After Customers have picked out the merchandise they wish to buy, they can draw three balls from an urn to determine the sum of the discount they will receive on their purchase. The balls value is as follows Yellow =1 Blue =2 Red = 3 Purple =4 Orange =5 Green = 6 Maroon=7 and Black=8. There are three balls of each color in the urn. The balls are drawn without replacement by each customer but returned to the urn before the next customer draws.

Jerry would like you to simulate 1000 sets of random draws storing the sums in a tally array. Print out the values of the tally array along with an analysis of the cost of the promotion.

(Hint: Enums, Vectors, Rand, and Tally arrays maybe useful)

Build a vector or an array ( probably called Urn) size [24]

Create a rand object range to start at 24 , 23, 22

For loop for 1000 draws

Add the value of three balls to give discount

Tally Array counts the occurrence of each answer

Tally Array [25] note 0,1,2,are always going to be empty

int tally [25] = {0};

total = ball1+ball2 +ball3;

tally[total]++;

grandtotal +=total

average = grandtotal /draw

median = middle value

mode = highest tally

Average = median = mode It is a normal distribution

Your print to monitor is a list of the the tally array and the average

OUTPUT :

Discounts of 3% = 1

Discounts of 4% = 4

Discounts of 5% = 7

........

Discounts of 24% = 0

The average discount was 13.5%

Your results will vary every time the program is run because it is random

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<cstdlib>



using namespace std;

int main() {
        int draw = 1000;
        int tally [25] = {0};
        int grandtotal = 0;

        for(int i=0; i<draw; i++) {
                int b1 = 1 + rand() % 8;
                int b2 = 1 + rand() % 8;
                int b3 = 1 + rand() % 8;
                int total = b1 + b2 + b3;
                tally[total]++;
                grandtotal +=total;
        }

        double avg = grandtotal /draw;
        
        for(int i=3; i<=24; i++) {
                cout << "Discounts of " << i << "% = " << tally[i] << endl;
        }
        cout << "Average Discount % = " << avg << endl;
        return 0;
}

please upvote. Thanks!

Add a comment
Know the answer?
Add Answer to:
C++ Jerry’s Appliance has a special promotion for its week long Anniversary Sale. After Customers have...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT