part_a: pi_approximator
is a mathematical quantity that associates the area of a circle to its radius. Write a program that approximates the value of by using the Leibniz formula:
Since this formula is an infinite series, you will need to prompt the user for how accurate they want the calculation to be. Rather than using one big pile of main( ), you need to use functions for this calculation and pass parameters and work with return values. In addition, you need to include atleast one const int or const double declaration. Finally, embed your program in a loop so that the calculation can be repeated as often as the user wishes. Round to two decimal places.
Iterations: 1Pi is approximated to be 4.00. |
Iterations: 2Pi is approximated to be 2.67. |
Iterations: 10Pi is approximated to be 3.04. |
- Write a program which produces this output as the examples above:
Iterations: {USER INPUT}Pi is approximated to be {approximation rounded to 2nd decimal place}. |
- You are provided the flexibility to create your own files.
- While there will likely be mutliple methods, the main method must be named getPi(…) as a simple interface to a user.
part_b: inventory_system
Write a C++ program that calculates the inventory on-hand for Widget Co, an internationally renowned Widget maker located in Santa Monica. Each month, Widget Co. produces 123 new widgets from its production line during a good month, but only 52 widgets from its production line during a bad month. In addition, each month, its sales team takes orders for some number of widgets. If they are on-hand, Widget Co. reduces its inventory of widgets. If not on-hand, it compiles a back-order for the requested widgets. In order to receive full credit, you must use functions for this calculation and pass parameters and work with return values. The program dialogue should look like this:
Welcome to Widget Co.!Month: 0 Number of widgets on-hand: 0 Number back-ordered: 0Was it a good or bad month (g/b)? gHow many did the sales force sell? 15Continue(y/n)? yMonth: 1 Number of widgets on-hand: 108 Number back-ordered: 0Was it a good or bad month (g/b)? bHow many did the sales force sell? 150Continue(y/n)? yMonth: 2 Number of widgets on-hand: 10 Number back-ordered: 0Was it a good or bad month (g/b)? bHow many did the sales force sell? 100Continue(y/n)? yMonth: 3 Number of widgets on-hand: 0 Number back-ordered: 38Was it a good or bad month (g/b)? gHow many did the sales force sell? 200Continue(y/n)? nAt the end of month 3, you wound up with 0 widgets on-hand and 115 widgets back-ordered |
- Again, you are expected to create all files.
- The main high level method must be named runInvSys(…).
Overall
- Your submission should follow this organization:
- part_a
- main.cpp
- my_pi_approximator.h
- my_pi_approximator.cpp
- part_b
- main.cpp
- my_inventory_system.h
- my_inventory_system.cpp
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.