[SOLVED] Engineering-Computation Homework 2

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon HW2-mtqfjh.zip (182.8 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product
  1. Write a program that calculates the volume of a washer (as pictured below). The program will ask the user for the two radii, r​1​ and r​2,​ and the height of the washer, then will send these parameters to a function to compute the volume, and lastly output the volume to the screen. Don’t forget units and make sure to allow the user to input decimal measurements. Submit a screenshot of the results and your code.
  2. Write a program that creates a linear congruential pseudorandom number generator (LCG). Remember, LCGs have the form

    rn+1 = (grn + c)(mod p)

    Use a modulus of 22​ 4​ so as not to overflow a l​ ong int​ (which has a limit
    generally of 23​ 1​ – 1 or approximately 2e9), and a multiplier of 61 with an adder of 1. Write the LCG within a function, ​randlcg(),​ which when called will return the next random number in the sequence, keeping track of where it is. Note that in order to keep track of where it is, the ​randlcg()​ function only needs to remember the last random number it returned. Use a seed of 100,001. Normalize your LCG so that it returns random numbers in between 0 and 1.
    Print the first 30 random numbers to the screen and submit a screenshot of
    the results and your code.

  • HW2-mtqfjh.zip