Question

MATLAB PROBLEM. You must prepare the code in Matlab for the following problem: A company with...

MATLAB PROBLEM.

You must prepare the code in Matlab for the following problem:

A company with 100 employees wants to give a gift to each employee

for this Christmas. Make a program in Matlab that randomly

Designate the gift for each employee with the following probability: Bear

30% of probability, box with 30% and 40% with the gift card. You must

use the for or while statutes within the solution. Shall

display something similar to the following:

EMPLOYEE 1 - CARD

EMPLOYEE - 2: TEDDY BEAR

EMPLOYEE 3: - BOX WITH

CHOCOLATES ...

EMPLOYEE 100 - GIFT CARD ...

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

for i=1:100
fprintf('EMPLOYEE %-3d - ',i)
gift=rand;
if gift<.3
fprintf('TEDDY BEAR\n')
elseif gift<.6
fprintf('BOX WITH CHOCOLATES\n')
else
fprintf('GIFT CARD\n')
end
end

Add a comment
Know the answer?
Add Answer to:
MATLAB PROBLEM. You must prepare the code in Matlab for the following problem: A company with...
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