$30
1. Write a program that calculates the volume of a washer (as pictured below). The program will ask the user for the two radii, r1 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 231 24 so as not to overflow a long int (which has a limit generally of 2 – 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.