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

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

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

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

  • Problem 1: Implement an algorithm to generate prime numbers. You will need to implement the following...

    Problem 1: Implement an algorithm to generate prime numbers. You will need to implement the following ingredients (some of them you developed for earlier assignments): 1. A method to generate random binary numbers with n-digits (hint: for the most significant digit, you have no choice, it will be 1; similarly, for the least significant digit there is no choice, it will have to be 1; for all other position, generate 0 or 1 at random) 2. A method to compute...

  • C++ Modify this program (or create your own) so that it performs the following tasks: 1....

    C++ Modify this program (or create your own) so that it performs the following tasks: 1. Insert the numbers into the list in sorted order (ascending). This will require you to keep the list sorted as you continue to insert new numbers. 2. When adding a new number, first check to see whether it is larger than the last number currently in the list. If it is, add it directly to the end of the list, i.e., do not traverse...

  • Problem 5 . This question considers uniform random points on the unit disc x2+92 〈 1...

    Problem 5 . This question considers uniform random points on the unit disc x2+92 〈 1 (a) A point (X, Y) is uniformly chosen in the unit disc. Find the CDF and PDF of its distance from the origin R X2 +Y2 (b) Compute the expected distance from the origin. (c) Determine the marginal PDF of X and Y (d) Are X and Y independent? (Justify your claims) e) One way to generate uniform random points on this disc is...

  • here is the dice images you need to use Problem 1/5 (20 points) Create a JavaFX...

    here is the dice images you need to use Problem 1/5 (20 points) Create a JavaFX application that simulates the rolling of a pair of dice. When the user clicks a button, the application should generate two random numbers, each in the range of 1 through 6, to represent the value of the dice. Use ImageView component to display the dice. Six images are included in the project folder for you to use. For example, the first picture below is...

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