View the step-by-step solution to:

This needs to be coded in C++ Lab 2: Earning Gear You will implement a program that hands out gear to the players of a particular game.

Please help with the following. This needs to be coded in C++



Lab 2: Earning Gear

You will implement a program that hands out gear to the players of a particular game. You may

theme your game as you wish.

Your program will use probabilities to decide what gear to hand out to the player. The gear includes

a dagger, a helment, a shield, and armor.

Your Program

All of the gear that will be handed out is represented by a token in a bag. To begin, there are 2

daggar tokens, 3 helmet tokens, 3 shield tokens, and 4 armor tokens in the Token Bag.

The program will choose a token from the bag and give that gear to the player. To simulate which

token was chosen, you will compute the probability of choosing each piece of gear and hand out

the gear with the highest probability of being chosen. If there is a tie, the user gets both (or all)

of the gear with the same probability.

You should display the probabilities of each kind of gear in a table before handing out the gear.

See the sample output for how to format the probabilities.

Remember, you cannot directly compare doubles. You have to compare using abs(x-y) < EPSILON

where EPSILON is some very small number, like 1e-14.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question