Question

LabVIEW Homework (On NI LabVIEW Program) Write a program to simulate an experiment of flipping a...

LabVIEW Homework (On NI LabVIEW Program)

Write a program to simulate an experiment of flipping a coin a number of times (for example 100 times), and show the number of times getting heads and tails respectively. You can use random numbers to simulate the experiment. If the random number is >0.5, you can assume it is one side (for example Head), otherwise is the other side (for example Tail).

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

//As you didnt specify language ,I have used C to program:

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

int main()

{

float random;

for(int i=0;i<100;i++)

{

random=(float)rand()/RAND_MAX;//get decimal randome number

if(random >0.5){//if it is greater than 0.5 thenprint below

printf("i value %d:Head \n",i);

}else{//else print below

printf("i value %d :Tail\n",i);

}

}

return 0;

}

//Output:

C: \Users \Ramcharan.Palnati\Desktop gcc Avg.c -o Avg C: \Users \Ramcharan.Palnati\Desktop Avg i value eTail i value 1:Head i

Add a comment
Know the answer?
Add Answer to:
LabVIEW Homework (On NI LabVIEW Program) Write a program to simulate an experiment of flipping a...
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
  • Random Number Generation and Static Methods Write a program that simulates the flipping of a coin...

    Random Number Generation and Static Methods Write a program that simulates the flipping of a coin n-times to see how often it comes up heads or tails. Ask the user to type in the number of flips (n) and print out the number of times the coin lands on head and tail. Use the method ‘random()’ from the Math class to generate the random numbers, and assume that a number less than 0.5 represents a tail, and a number bigger...

  • 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

  • Question is are X and Y independent? Why? 1. Consider flipping a fair coin three times...

    Question is are X and Y independent? Why? 1. Consider flipping a fair coin three times and observe whether it lands heads up or tails up. Let X the number of switches from either head to tail or vice versa. For example, when THT is observed, the number of switches is 2 and when HHH is observed, the number of switches is 0. Also, let Y be the number of tails shown in the three times of flipping.

  • "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...

  • 1. Consider flipping a fair coin three times and observe whether it lands heads up or...

    1. Consider flipping a fair coin three times and observe whether it lands heads up or tails up. Let X the number of switches from either head to tail or vice versa. For example, when THT is observed, the number of switches is 2 and when HHH is observed, the number of switches is 0. Also, let Y be the number of tails shown in the three times of fipping. (a) List all the values of the joint probability mass...

  • Write a program where 3 separate threads simulate flipping a coin. The 3 threads should execute concurrently and each thread should do 1000 flips. Keep track of what is currently the record number of...

    Write a program where 3 separate threads simulate flipping a coin. The 3 threads should execute concurrently and each thread should do 1000 flips. Keep track of what is currently the record number of consecutive heads/tails (separately) and which thread produced that sequence. Every time a thread produces a longer sequence, display a message on the screen. Make sure other threads can’t interfere when updating the current record. N.B: This is a java object oriented program assignment.

  • Write a program that simulates the toss of a coin. Whenever a coin is tossed the...

    Write a program that simulates the toss of a coin. Whenever a coin is tossed the result will be either a head or tail. Prompt the user as shown by entering an ‘H’ for heads or ‘T’ for tails. Use a loop for input validation of an ‘h’ or ‘t’. Make sure that both an upper case and lower case will be accepted. Have the computer generate a random number. Assign a char variable a (‘h’ ^ ’t’) head or...

  • 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...

  • # JAVA Problem Toss Simulator Create a coin toss simulation program. The simulation program should toss...

    # JAVA Problem Toss Simulator Create a coin toss simulation program. The simulation program should toss coin randomly and track the count of heads or tails. You need to write a program that can perform following operations: a. Toss a coin randomly. b. Track the count of heads or tails. c. Display the results. Design and Test Let's decide what classes, methods and variables will be required in this task and their significance: Write a class called Coin. The Coin...

  • In NI LabVIEW please, Construct a VI that displays a random number between 0 and 1...

    In NI LabVIEW please, Construct a VI that displays a random number between 0 and 1 once every second. Also, compute and display the average of the last four random numbers generated. Display the average only after four numbers have been generated; otherwise display a 0. Each time the random number exceeds 0.5, generate a beep sound using the Beep.vi.

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