Question

Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, what output is expe
The area of the circle would be nr where r is 1. The area of the square is s where s is 2 (-1 to 1). Therefore the ratio of t
FPRN-(10.0-(-1.5)) GWRN/MRN +(-1.5) or FPRN-(11.5) GWRN/MRN-1.5


The Greatest and Least of These Write a program with a loop that lets the user enter a series of integers, followed by -99 to
Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, what output is expected, the step by step process (algorithm) to get the output from the input, and test data (input for which you know the expected output) for each of the 3 problems given below. You should not write any actual C++ code. Make sure the problem statement is in your own words and is descriptive enough so someone not reading the problem given to you will understand what needs to be done. (See the document containing example algorithms posted on Canvas for Algorithms 1). Attach your file to the Algorithms 3 submission on Canvas Problem 1: Create a process that will generate a random whole number between 1 and 10000. Ask the user to enter a guess and state if the guess is correct, lower than the generated number, or higher than the generated number. Repeat the guessing process until the user has guessed the generated number. Count the number of guesses the user entered. Problem 2: Create a process to complete Programming Challenge 13 of Chapter 5 (The Greatest and Least of These). Problem 3: A specific form of bacteria has been measured to triple each day. Create a process that will ask the user to enter the initial number of cells (day 0). Then create a table that will output the day and the number of cells for days 1 through 10. Do not use exponentiation for this problem. Problem 4: (for this problem your algorithm should be C++ specific and you should describe how the C++ rand function will be employed). Write a process that will use the Monte Carlo method to estimate PI as described below. The Monte Carlo method to estimate probability generates a large number of points then determines how many points meet a specific condition. Consider the figure below containing a square with a circle inside of it, both of which are centered on zero. -1
The area of the circle would be nr where r is 1. The area of the square is s where s is 2 (-1 to 1). Therefore the ratio of the suppose we generate random points to fall uniformly in the area of the square (x varies from -1 to 1 and y varies from-1 to 1). We can state ratio of the number of points falling inside the circle to the total number of the points is equal to the ratio of the area of the circle to the area of the of the circle to the area of the square would be r/4. Now area nbs /4-(number of points in the circle)/(total number of points) Therefore r can be defined by the equation (number of points in the circle)/(total number of points) 4 Generate a process that would generate random numbers between-1 and 1 for x and y positions of 10000 points and count how many points fall with the circle, then determine an estimated version of z. (See below to generate floating point random numbers. This generation is not needed to describe the process, but to implement the process) Generating uniformly distributed random floating point numbers. From Chapter 3, you know that the rand function in C++ generates whole numbers between 0 and a maximum number. If we want to generate random floating point numbers with in a given span we can use the formula FPRN span * GRWN/MRN + offset where FPRN is a floating point random number, span is the maximum floating point number that should be generated- the minimum floating point number that should be generated, GRWN is the generated random whole number that the C++ rand() function will produce, MRN is the maximum number that the rand() function will produce, and offset is the minimum number that should be generated. For example, suppose we want to generate random floating point numbers between 0 and 5. The span would be 5, and the offset would be 0 so the formula would be FPRN-5.0 GWRN/MRN +0 However, if we wanted to generate floating point numbers between -2 and 3, the span would still be 5 but the offset would now be -2. Therefore the formula would be FPRN 5.0 GWRN/MRN + (-2) or FPRN-5.0 GWRN/MRN-2 Similarly if we wanted to generate random floating point numbers between -1.5 and 10, the formula would be
FPRN-(10.0-(-1.5)) GWRN/MRN +(-1.5) or FPRN-(11.5) GWRN/MRN-1.5
The Greatest and Least of These Write a program with a loop that lets the user enter a series of integers, followed by -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Problem Statement : We need will generate a random number between 1 to 10000. The user tries to guess the number and keep on guessing until he is correct. For each guess made by the user, we tell him whether his guess was higher than, lower than or equal to the generated number. In the end we also print the number of guesses the user took to find the correct number.

Input : A number between 1 to 10000 (user's guess)

Output : Whether the guess is "higher", "Lower" or "correct".

Test Data :

Number guessed : 10

Input : 100

Output : Higher

Input : 50

Output : Higher

Input : 20

Output Higher

Input : 1

Output : Lower

Input : 10

Output: Correct

Number of guesses = 5

Algorithm :

  1. num = rand()%10000 + 1
  2. count = 0
  3. do{
    1. guess = Input()
    2. count = count + 1
    3. if (num == guess) {
      1. print "Correct"
      2. print "Number of guesses is" + count
      3. break}
    4. else if (num<guess)
      1. print "Higher"
    5. else
      1. print "Lower"
  4. }while(true)
Add a comment
Know the answer?
Add Answer to:
Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, w...
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
  • Write a Java program that uses the Monte Carlo method to estimate the value of PI....

    Write a Java program that uses the Monte Carlo method to estimate the value of PI. This method uses the unit circle inscribed in a square with sides of length 2 and random numbers to perform the estimation. The estimation works as follows: • Two random numbers are generated during each iteration of a loop. • The random numbers are each in the range of -1 to 1. One random number is the x-coordinate and the other is the y-coordinate....

  • Labview question: Create a VI using a While Loop that continuously generates random numbers between 0...

    Labview question: Create a VI using a While Loop that continuously generates random numbers between 0 and 1000 until it generates a number that matches a number selected by the user. Determine how many random numbers the VI generated before the matching number. conditions to applied on above problem: 1. Convert the “random number” generator floating point numerical output to integer values to make it easier to find a match. 2. The “user selected number control” should be on the...

  • The program will need to accept two input arguments: the path of the input file and...

    The program will need to accept two input arguments: the path of the input file and the path of the output file. See etc/cpp/example.ifstream.cpp for the basis of how to do this. Once the input and output file paths have been received, the program will need to open the input and output files, read and process each input file line and create a corresponding output file line, close the input and output files, and then create and output some summary...

  • I need to create a bit of code for javascript which I can have random numbers...

    I need to create a bit of code for javascript which I can have random numbers generate with a certain amount of digits set by the user. and ask the user how many times they want this to happen. For example The user says they want a number with 4 digits (any number between 0 - 9999) and the user can input if they want to add, subtract, multiply, divide, or make it random 2 random numbers are generated. First...

  • (b) What is the probability of generating a random number between 0.35 and 0.65? (c) What...

    (b) What is the probability of generating a random number between 0.35 and 0.65? (c) What is the probability of generating a random number with a value less than or equal to 0.20? (d) What is the probability of generating a random number with a value greater than 0.60? (e) Generate 50 random numbers by entering =RAND() into 50 cells of an Excel worksheet. This answer has not been graded yet. (f) Compute the mean and standard deviation for the...

  • 4. 3/6 points Previous Answers ASWSBE13 6.2.004. My Notes Ask Your Teacher Most computer languages include...

    4. 3/6 points Previous Answers ASWSBE13 6.2.004. My Notes Ask Your Teacher Most computer languages include a function that can be used to generate random numbers. In Excel, the RAND function can be used to generate random numbers between 0 and 1. If we let x denote a random number generated using RAND, then x is a continuous random variable with the following probability density function. ROX) i for 0 SX S1 10 elsewhere (a) Graph the probability density function....

  • Write a PYTHON program that will approximate the value of π. You can do this by...

    Write a PYTHON program that will approximate the value of π. You can do this by computing π to be the ratio of the area of a circle to the area of the square that bounds that circle. Assume a circle of radius 0.5 enclosed by a 1x1 square. The area of the circle then is πr^2=π/4, since r=0.5=1/2 and the area of the square is 1. To approximate the ratio, take a large number of uniformly distributed random points....

  • Write a program that writes a series of random numbers to a file. Each random number...

    Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file     and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...

  • C++ Guessing game. Create a project titled Lab4_Guess with a single file titled guess.cpp Program the...

    C++ Guessing game. Create a project titled Lab4_Guess with a single file titled guess.cpp Program the following game. The computer selects a random number between 1 and 100 and asks the user to guess the number. If the user guesses incorrectly, the computer advises to try larger or smaller number. The guessing repeats until the user guesses the number. The dialog should look as follows (user input is shown in bold): Guess a number between 1 and 100: 50 try...

  • last 2pictures are lab7,just need to do the first picture,dont do the lab 7 Functional π...

    last 2pictures are lab7,just need to do the first picture,dont do the lab 7 Functional π Take the sample solutions for approximating π from labZ and put each solution into its own function. You'll need to decide: 1. What are the inputs that this function requires? 2. What is the output that this function produces? 3. What is an appropriate name for this function? You should create 3 separate functions 1, One that approximates π using the area of a...

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