Question

Develop a solution to flip a coin a given amount of times, and then print the...

Develop a solution to flip a coin a given amount of times, and then print the number of heads and the number of tails. The equation to toss the coin is:

Coin = Integer(Random * 2) + 1

Include a PAC and Algorithm.

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

Solution

PAC

ALGORITHM

Algorithm

Control Module

1)Process read data (Counter)Read DataCalculatePrint
2.While counter > 0 Counter decrementProcess calculate (head and tail)
3) Whileend
4) Process print
5) End

Read Module

1) Read number of toss
2) End

Calculate Module

1) Create toss
2) If true:
3) Increase head count
4) Else
5) Increase tail count
6) End

Print Module

1) Print the number of heads and tails
2) End

Add a comment
Know the answer?
Add Answer to:
Develop a solution to flip a coin a given amount of times, and then print the...
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
  • Simulate the flipping of a coin Print the result of the coin flip : use off...

    Simulate the flipping of a coin Print the result of the coin flip : use off numbers for Heads . and even numbers for Tails Update the number of times the result is Heads Update the number of times the coin has been flipped struct coin_prob{ int heads; int flips; }; void coin_flip(struct coin_prob * coin); You may use a rand functioon (assume its already been seeded), but no other pre-defined function

  • Flip a coin 10 times and record the observed number of heads and tails. For example,...

    Flip a coin 10 times and record the observed number of heads and tails. For example, with 10 flips one might get 6 heads and 4 tails. Now, flip the coin another 20 times (so 30 times in total) and again, record the observed number of heads and tails. Finally, flip the coin another 70 times (so 100 times in total) and record your results again. We would expect that the distribution of heads and tails to be 50/50. How...

  • In C++ please Create a coin-flipping game. Ask the user how many times to flip the...

    In C++ please Create a coin-flipping game. Ask the user how many times to flip the coin, and use the random function to determine heads or tails each time a coin is flipped. Assume the user starts with $50. Every time the coin is flipped calculate the total (heads +$10, tails -$10). Create another function to test if the user has gone broke yet (THIS FUNCTION MUST RETURN A BOOLEAN TRUE/FALSE VALUE). End the program when the user is broke...

  • "Flip a Coin!" You will write a program that allows the user to simulate a coin...

    "Flip a Coin!" You will write a program that allows the user to simulate a coin flip. Note the following line of code: (Math.random()*2) +1; This line generates a random number (a float) between 1 and 2. If you wanted to simulate somebody rolling a die, you could store the value of this variable as: var coinFlip = (Math.random()*2) +1; (Be sure to include all the parentheses in this line of code.) Reminder - Of course, you’ll need to convert...

  • Write a C++ program that simulates coin tossing. For each toss of the coin the program...

    Write a C++ program that simulates coin tossing. For each toss of the coin the program should print Heads or Tails. The program should toss a coin 100 times. Count the number of times each side of the coin appears and print the results at the end of the 100 tosses.   The program should have the following functions as a minimum: void toss() - called from main() and will randomly toss the coin and set a variable equal to the...

  • 2. SUPPLEMENTAL QUESTION 1 (a) Toss a fair coin so that with probability pheads occurs and...

    2. SUPPLEMENTAL QUESTION 1 (a) Toss a fair coin so that with probability pheads occurs and with probability p tails occurs. Let X be the number of heads and Y be the number of tails. Prove X and Y are dependent (b) Now, toss the same coin n times, where n is a random integer with Poisson distribution: n~Poisson(A) Let X be the random variable counting the number of heads, Y the random variable counting the number of tails. Prove...

  • 1. Multiple choice. Circle all the correct answers a) You flip a coin 100,000 times and...

    1. Multiple choice. Circle all the correct answers a) You flip a coin 100,000 times and record the outcome in a Xi 1 if the toss is "Heads" and 0 if its "Tails. The Law of Large Numbers says that: i. ii. It is impossible for the first n flips to all be "Heads" if n is large. With high probability, the share of coin flips that are "Heads" will approximate 50%. The sample mean of X is always 0.5...

  • find correlation using covariance ? 1. (No key parameter) We flip a fair coin with the...

    find correlation using covariance ? 1. (No key parameter) We flip a fair coin with the outcomes X = +1 for heads, and X = -1 for tails, we also toss a fair die with the outcome Y E (1,2,3,4,5,6) the number of dots on the face up. Find the correlation of the random variables E[XY] =? Use the covariance equation to prove your answer. ccc -0.2v .

  • Answer part a and part b please!!! (a) What is the conditional probability that exactly four Tails appear w when a fair coin is flipped six times, given that the first flip came up Heads? (I.e. the co...

    Answer part a and part b please!!! (a) What is the conditional probability that exactly four Tails appear w when a fair coin is flipped six times, given that the first flip came up Heads? (I.e. the coin , then is flipped five more times with Tails appearing exactly lour times.) (b) What if the coin is biased so that the probability of landing Heads is 1/3? (Hint: The binomial distribution might be helpful here.) (a) What is the conditional...

  • One application of an absolute value inequality is the concept of the unfair coin. If a coin is tossed 100 times, w...

    One application of an absolute value inequality is the concept of the unfair coin. If a coin is tossed 100 times, we would expect approximately 50 of the tosses to be heads; however this is rarely the case.1. Toss a coin 100 times to test this hypothesis. Record the number of times the coin is heads and the number of times the coin is tails on the lines below. You may want to ask someone to tally the results of...

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