Question

In: Computer Science

Write a menu-driven program to handle the flow of widgets into and out of a warehouse....

Write a menu-driven program to handle the flow of widgets into and out of a warehouse.

    The warehouse will have numerous deliveries of new widgets and orders for widgets

    The widgets in a filled order are billed at a profit of 50 percent over their cost

    Each delivery of new widgets may have a different cost associated with it

    The accountants for the firm have instituted a last-in, first-out system for filling orders

        the newest widgets are the first ones sent out to fill an order and the most recent orders are filled first

        partial shipments allowed

            10 widgets were ordered and warehouse has only 4 available, ship 4, the remainder 6 will be shipped later

     Assign unique numbers to each order and each delivery

    This function of inventory can be represented using two stacks: orders-to-be-filled and widgets-on-hand. When delivery of new widgets is received, any unfilled orders (on the orders-to-be-filled stack) are processed and filled. After all orders are filled, if there are widgets remaining in the new delivery, a new element is pushed onto the widgets-on- hand stack. When an order for new widgets is received, one or more objects are popped from the widgets-on-hand stack until the order has been filled.

    If the order is completely filled and there are widgets left over in the last object popped, a modified object with the quantity updated is pushed onto the widgets-on-hand stack.

    If the order is not completely filled, the order is pushed onto the orders-to-be-filled stack with an updated quantity of widgets to be sent out later.

    After an order is fully or a partially filled display the following in the format shown below:

        order number

        quantity ordered

        quantity shipped

        price per widget and the total cost for all widgets in the order

        indicate whether there are any widgets remaining to be sent out at a later time.

    After delivery is processed, display information about each order that was filled with this delivery.

    Keep track of the number of widgets in stock and the number of widgets shipped.

   Make sure each function definition is preceded by a description, post/preconditions

    Create menu options to display the details of the inventory on hand ( delivery stack) and the details of the outstanding orders (shipment/order stack)

    You may implement the stack as an array or a linked list

    Well format the output: all numbers should be right-aligned; see the sample below

    Create a test plan ( hand-written or typed); the test plan has to be approved for the instructor before you can submit the lab.

Order Number 123                                       

Qty to Ordered 25                                          

Qty Shipped this Shipment           10                                          

Qty to be Shipped            5                                            

Total Cost to the Warehouse       28.25                                    

Total Cost to the Customer          42.38                                    

Profit this Shipment       14.13                                    

                                                               

Shipment details                                                             

Delivery #            Qty Shipped       Unit Price            Cost to the Warehouse Cost to the Customer

621        5             2.5          12.5       18.75

620        3             1.75       5.25       7.88

619        2             5.25       10.5       15.75

Modify lab #5 Backwards Warehouse to work on first come first serve basis, first in - first out. The newest widgets are the last ones sent out to fill an order and the oldest and back orders are filled first. Use queue data structure implemented as a linked list..

The programming language will be in c++,but i need assistance in in the written code as well as having a test plan ( hand-written or typed); the test plan has to be approved for the instructor before you can submit the lab and for this program we will have the user one have one item and not multiple items and my professor claried that i use arrays for this lab and not linked list. the ouput need to match exactly what is displayed

Order Number 123                                       

Qty to Ordered 25                                          

Qty Shipped this Shipment           10                                          

Qty to be Shipped            5                                            

Total Cost to the Warehouse       28.25                                    

Total Cost to the Customer          42.38                                    

Profit this Shipment       14.13                                    

                                                               

Shipment details                                                             

Delivery #            Qty Shipped       Unit Price            Cost to the Warehouse Cost to the Customer

621        5             2.5          12.5       18.75

620        3             1.75       5.25       7.88

619        2             5.25       10.5       15.75

Solutions

Expert Solution

#ifndef _WIDGET_H
#define _WIDGET_H
#include <iostream>
#include <cstddef>

using namespace std;


class Widget
{
private:

double cost; // A widget has a cost.


public:

Widget(double c); // Default Constructor.
Widget(const Widget & aWidget); // Copy Constructor.
~Widget(); // Destructor.

void setCost(); // Setting the cost of the widget.
double getCost()const; // Getting the cost of the widget.


};// end class Widget

#endif

#include "Widget.h"


// Default Constructor.
Widget::Widget(double c)
: cost(c){}


// Copy Constructor.
Widget::Widget(const Widget & aWidget)
: cost(aWidget.cost){}


// Destructor
Widget::~Widget(){}


// Set the cost of the widget.
void Widget::setCost()
{
if (cost < 0.00)
cerr << "ERROR: Invalid cost.\n";
else
this->cost = cost;
}


// Get the cost of the widget.
double Widget::getCost()const
{
return this->cost;
}





#ifndef _Order_H
#define _Order_H
#include <iostream>
#include <cstddef>
#include "Widget.h"

using namespace std;


class Order
{
private:

int RemainingQty; // Storing the remaining qty of the widgets.
int TotalQty; // Storing the total qty of the widgets.

double TotalPrice; // Storing the total price of the widgets.
int OrderNo; // Storing the value of number of order.


public:

Order(int q, int on); // Default Constructor.
Order(const Order & aOrder); // Copy Constructor.
~Order(); // Destructor.

bool IsSatisfied(); // Return true is this order has been satisfied.
void Fulfill(double c); // Full this order by decreasing the amount of widgets it still requires @param cost of the widget.

void setTotalPrice(); // Setting the TotalPrice.
void setRemainingQty(); // Setting the RemainingQty.
void setTotalQty(); // Setting the TotalQty.
void setOrderNo(); // Setting the OrderNo.

double getTotalPrice()const; // Getting the TotalPrice.
int getRemainingQty()const; // Getting the RemainingQty.
int getTotalQty()const; // Getting the RemainingQty.
int getOrderNo()const; // Getting the RemainingQty.



};// end class Order

#endif

#include "Order.h"


// Default Constructor.
Order::Order(int q, int on)
:TotalQty(q), TotalPrice(0), RemainingQty(q), OrderNo(on) {}


// Copy Constructor.
Order::Order(const Order & aOrder)
: TotalQty(aOrder.TotalQty), TotalPrice(aOrder.TotalPrice), RemainingQty(aOrder.RemainingQty), OrderNo(aOrder.OrderNo) {}


// Destructor
Order::~Order(){}


// Return true is this order has been satisfied.
bool Order::IsSatisfied()
{
return RemainingQty == 0;
}


// Full this order by decreasing the amount of widgets it still requires @param cost of the widget.
void Order::Fulfill(double c)
{
RemainingQty--;
TotalPrice += c;
}


// Setting the TotalPrice.
void Order::setTotalPrice()
{
this->TotalPrice = TotalPrice;
}


// Setting the RemainingQty.
void Order::setRemainingQty()
{
this->RemainingQty = RemainingQty;
}


// Setting the TotalQty.
void Order::setTotalQty()
{
this->TotalQty = TotalQty;
}


// Setting the OrderNo.
void Order::setOrderNo()
{
this->OrderNo = OrderNo;
}


// Return the price of this order Acumulated over time.
double Order::getTotalPrice()const
{
return this->TotalPrice;
}



// Return the Remaining Qty of widgets this order still requires.
int Order::getRemainingQty()const
{
return this->RemainingQty;
}



// Return the total qty of the order.
int Order::getTotalQty()const
{
return this->TotalQty;
}


// Return Order No.
int Order::getOrderNo()const
{
return this->OrderNo;
}




//MAIN

#include <iostream>
#include "LinkedStack.h"
#include "Widget.h"
#include "Order.h"

using namespace std;

int main()
{

LinkedStack <Widget> Widgets_On_Hand;
LinkedStack <Order> Orders_To_Be_Filled;

int choice, num, qty, sv, i = 1;

bool flag = false, pful = false;

int oct = 1;
while (1)
{
cout << "*******************************************\n"
<< "\t 1.Add New Widgets To Inventory\n"
<< "\t 2.Place Order\n"
<< "\t 3.Quit\n"
<< "\t\tENTER YOUR SELECTION: \n";
cout << "*******************************************" << endl;

cout << "Please Enter You Choice:";
cin >> choice;

switch (choice)
{
case 1:
cout << "Enter the number of widgets arrived: ";
cin >> num;

sv = num;

while (num > 0)
{
double c;
cout << "Enter cost of widget:" << i << " :";
cin >> c;
Widget neww(c);
Widgets_On_Hand.push(neww);
i++;
num--;
}

i = 1;

while (!Orders_To_Be_Filled.isEmpty())
{
// Store the address of top value into the object of the class Order.
Order &o = Orders_To_Be_Filled.top();

while (!Widgets_On_Hand.pop())
{
// Store the address of top value into the object of the class Order.
Widget &w = Widgets_On_Hand.top();
o.Fulfill(1.5*w.getCost());
Widgets_On_Hand.pop();
sv--;
if (o.IsSatisfied())
{
flag = true;
break;
}

if (Widgets_On_Hand.isEmpty())
pful = true;
}

if (flag)
{
cout << endl << "\t\t Order No. \t" << o.getOrderNo() << " Fulfilled By This Delivery\n";
cout << "\t\t Total Quantity of Order:" << o.getTotalQty() << endl;
cout << "\t\t Total Cost of Order:" << o.getTotalPrice() << endl;

Orders_To_Be_Filled.pop();

flag = false;
}

else
{
if (pful)
{
cout << endl << "\t\t Order No.\t" << o.getOrderNo() << "Partially Fulfilled By This Delivery\n";
cout << "\t\t Total Quantity of Order:" << o.getTotalQty() << endl;
cout << "\t\t Remaining Quantity of Order:" << o.getRemainingQty() << endl;
cout << "\t\t Total Cost of Order:" << o.getTotalPrice() << endl;
}

pful = false;
break;
}
}

if (!Widgets_On_Hand.isEmpty())
cout << "\n\n\t\t Total Number of widgets stored in Wharehouse:" << sv << endl;
break;

case 2:

cout << "\n\t\t Enter the Quantity:";
cin >> qty;

if (qty > 0)
{
Order o(qty, oct++);
while (!Widgets_On_Hand.isEmpty())
{
if (o.IsSatisfied())
{
flag = true;
break;
}

Widget &w = Widgets_On_Hand.front();
o.Fulfill(1.5*w.getCost());
Widgets_On_Hand.pop();
}

if (flag)
{
cout << endl << "\t\t Order No.\t" << o.getOrderNo() << " Fulfilled \n";
cout << "\t\t Total Quantity of Order:" << o.getTotalQty() << endl;
cout << "\t\t Total Cost of Order:" << o.getTotalPrice() << endl;

flag = false;
}

else
{
cout << endl << "\t\t Order No.\t" << o.getOrderNo() << "Is Not Fulfilled\n";
cout << "\t\t Total Quantity of Order:" << o.getTotalQty() << endl;
cout << "\t\t Remaining Quantity of Order:" << o.getRemainingQty() << endl;
cout << "\t\t Total Cost of Order:" << o.getTotalPrice() << endl;

Orders_To_Be_Filled.push(o);
}
}

break;

case 3:
exit(1);
default:
cout << endl << "Wrong Choice\n";
}
}

system("pause");
return 0;

}


Related Solutions

This is an exercise for a menu-driven program. Program should use shell functions. Write a program...
This is an exercise for a menu-driven program. Program should use shell functions. Write a program that displays the following menu: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a rectangle 3. Calculate the area of a triangle 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for the radius of the circle and then display the area. Use the following formula to calculate the circle’s area: ?...
Write a menu-driven program to test the three functions conver_tlength(), convert_width(), convert_volume() in a program. Program...
Write a menu-driven program to test the three functions conver_tlength(), convert_width(), convert_volume() in a program. Program should allow the user to select one of the options according to whether lengths, weights or volume are to be converted, read the volue to be converted and the units, and then call the appropriate function to carry out the conversion In unit out unit I C (inch to centimeter 1 in = 2.4 cm) F C (feet to centimeter 1 ft = 30.4...
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java...
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java program that will solve the following problem. The program uses one and two-dimensional arrays to accomplish the tasks specified below. The menu is shown below. Please build a control panel as follows: (Note: the first letter is shown as bold for emphasis and you do not have to make them bold in your program.) Help SetParams FillArray DisplayResults Quit Upon program execution, the screen...
Write a menu driven C++ program that prints the day number of the year , given...
Write a menu driven C++ program that prints the day number of the year , given the date in the form of month-day-year. For example , if the input is 1-1-2006 , then the day number is 1. If the input is 12-25- 2006 , the day number is 359. The program should check for a leap year. A year is leap if it is divisible by 4 but not divisible by 100. For example , 1992 , and 2008...
Java Write a menu driven program that implements the following linked list operations : INSERT (at...
Java Write a menu driven program that implements the following linked list operations : INSERT (at the beginning) INSERT_ALPHA (in alphabetical order) DELETE (Identify by contents, i.e. "John", not #3) COUNT CLEAR
C++ ^ ^ Write a menu driven program to perform following operations using a map container...
C++ ^ ^ Write a menu driven program to perform following operations using a map container that stores the information about USA Population (In Million). @@@Menu@@@ 1. Add Information 2. Display Information 3. Update Information 4. Erase Information 5. Clear Information For example, Suppose the map initially contains following information (Use emplace() function to store the information) 2010, 309.33 2011, 311.58 2012, 313.87 2015, 320.74 2016, 323.07 The program should produce the desired output when a valid input is provided,...
Write a menu driven Java program which uses a method for each of the following operations:...
Write a menu driven Java program which uses a method for each of the following operations: (Note : The user should be allowed to repeat the operations as long as he wants to. Use appropriate number of parameters and return type for each method.) A. to find the sum of the following series (up to N terms). The program should    display the terms:              22 + 42 + 62… For example, if N=4, then the program should display the following...
Write a simple menu-driven program called “Million Dollar Game”. The dice that we are using for...
Write a simple menu-driven program called “Million Dollar Game”. The dice that we are using for this game are special oriental dice. Each die has six different patterns. The six possible patterns are: Fish, Shrimp, Crab, Chicken, goldenCoin, Barrel. This game has three dice. In this game, the player can place his or her bet on any die-pattern. The amount of the winning prize is directly proportional to the number of matched dice after the two dice have been tossed...
Write a modularized, menu-driven program to read a file with unknown number of records. Input file...
Write a modularized, menu-driven program to read a file with unknown number of records. Input file has unknown number of records of inventory items, but no more than 100; one record per line in the following order: item ID, item name (one word), quantity on hand , and a price All fields in the input file are separated by a tab (‘\t’) or a blank ( up to you) No error checking of the data required Create a menu which...
Write a menu-driven C++ program with two options: 1) Is it odd or even? 2) End...
Write a menu-driven C++ program with two options: 1) Is it odd or even? 2) End Program.The user can only input a positive integer (0 does not count) and if the input is not a positive integer the program must state "Invalid Input." The program must determine whether the input is even or odd. The program must use functions and can only use the iostream and iomanip libraries. Note: The program must loop until the 2nd menu option is chosen.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT