CS 52: Assignment #3 Solved

25.00 $

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

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (2 votes)

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: 1
Pi is approximated to be 4.00.
Iterations: 2
Pi is approximated to be 2.67.
Iterations: 10
Pi 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: 0
Was it a good or bad month (g/b)? g
How many did the sales force sell? 15
Continue(y/n)? y

Month: 1    Number of widgets on-hand: 108  Number back-ordered: 0
Was it a good or bad month (g/b)? b
How many did the sales force sell? 150
Continue(y/n)? y

Month: 2    Number of widgets on-hand: 10  Number back-ordered: 0
Was it a good or bad month (g/b)? b
How many did the sales force sell? 100
Continue(y/n)? y

Month: 3    Number of widgets on-hand: 0 Number back-ordered: 38
Was it a good or bad month (g/b)? g
How many did the sales force sell? 200
Continue(y/n)? n

At 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
  • 03_pi_inventory.zip