part_b: inventory_system Write a C++ program that calculates the inventory on-ha
ID: 3587782 • Letter: P
Question
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(...)
Can you also show how to set this up on 3 files so that you have
main.cpp
my_inventory_system.h
my_inventory_system.cpp
i dont understand how to split them up into 3 files 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
Explanation / Answer
just right your function definations in the my_inventory_system.h file.
include the above created header and then define the functions in my_inventory_system.cpp file and then compile it,
now as you have the set up ready just include the above created my_inventory_system.h into your c++ code as you will do in say for example
#include "my_inventory_system.h"
Now write the whole program using the functions created in those files and linking them together in the main.cpp file
When you complier the code , you will first need to compile my_inventory_system.cpp file and
link the files together by using gcc -o myprogram main.cpp my_inventory_system.cpp.
Thenn you can run the program the conventional way and it will work smoothly.
You may ask why so much trouble , then the answer will be to generate more general purpose and cleaner code.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.