Write an algorithm for sorting data in an array using C++
1) Draw functional block diagram 2) Write a pseudo code 3) Write actual code 4) Test and Debug 5) Format and write good comments.
A man on the street offers you a wager. He will fan out a deck of cards and let you pick one at random. If it’s a face card, he’ll give you $2. If it’s an ace, he’ll give you $4. If it’s anything else, you give him $1. What is the amount you are expected to win each time you play? Should you take his offer?
Total cards per deck = 52 Num of face cards = 3*4 = 12 Num of Aces = 1*4 = 4 Num of other cards = 9*4 = 36 Expected Win of face cards = 2 * 12/52 = 0.46 Expected Win of Aces = 4* 4/52 = 0.31 Expected Loss of other cards = 1* 36/52 = 0.69 Expected win = 0.46 + 0.31 - 0.69 = 0.08 You should take this bet as you will win an avg of 8 cents every bet in the long run.
A ball is dropped from a height of 58.8 meters with an initial speed of 19.6 meter per sec. The height of the ball at any instant is a function of time t and is defined by the equation h(t) = –4.9t^2 + 19.6^t + 58.8. When does the object strike the ground?
When the ball hits the ground, h(t) = 0. Use quadratic equation as below: 4.9t^2 + 19.6^t + 58.8 = 0 Using the quadratic equation: t = ( -b +/- sqrt(b^2 - 4ac) ) / (2a) This will give two values of t: t = -2 and t = 6 since t=-2 is not possible, only t=6 is the correct answer.