Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Inventory Management You have a business buying and selling Widgets. There are m

ID: 643133 • Letter: I

Question

Inventory Management You have a business buying and selling Widgets. There are many ways to keep track of your Widget inventory, but two common ways are LIFO and FIFO. The profit computed using the two methods will be very different. LIFO uses the cost of the Widgets bought last to compute profit. FIFO uses the cost of the Widgets bought first to compute the profit. Thus, since the cost of an item increases over time in an inflationary economy, LIFO reports lower profit than FIFO. LIFO is often used to report income for tax purposes, while FIFO is used to report profit to shareholders. 1. Create an array-based deque implementation (ArrayDeque). Your implementation should not use shifting. Instead, allow the items to move around the interior of the array. To do this, you will need to store both the index of the front and the back. Allow array resizing if the array runs out of room. The (public) operations required by the Deque ADT are listed in a Deque interface (Deque.h). 2. Create a deque-based stack (DequeStack) and a deque-based queue (DequeuQueue) using your ArrayDeque implementation. DequeStack has to extend abstract class Stack and have just one private field of type Deque. DequeQueue should be implemented analogically. 3. Implement the following methods of a WidgetManager: void buyWidgets(double cost, int numToBuy) double sellWidgets(double cost, int numToSell) 4. Test your implementation in the way you like. You may write a driver that will allow you to buy and sell Widgets and will report the profit (loss) when you sell Widgets. You may adapt Prof. Boshart's driver that can be downloaded from here: mboshart.dyndns.org/boshart/2110programs/prog2/InventoryDriver.cpp You may write google tests instead of the driver. Your tests won't be graded but your implementations of the above mentioned classes. Submit to the dropbox your implementation of the classes: - ArrayDeque (file ArrayDeque.h) - DequeStack (file DequeStack.h) - DequeQueue (file DequeStack.h) and functions buyWidets and sellWidgets (file WidgetManager.cpp) 4 files in total You don't have to provide any documentation for this project. Starting project can be found in the repository (InventoryManager) and additionally will be sent together (ZIPped) with this document. Interaction1 Sample interaction with the user. In this case user first chose LIFO management style and then he bought: 5 widgets, each worth $6 3 widgets, each worth $2 7 widgets, each worth $9 Next, he sold 8 widgets $20 each. In this way he gained $95, since he sold the last 7 widgets he bought, each of which was worth $9 (so he gained 7x($20-$9) = $77 on these widgets) and also 1 widget that he payed $2 for (so he gained 1x($20-$2)=$18). On this transaction he gained $95 (=$77+$18).

Explanation / Answer

1) ArrayDeque.h file

/* This file stores function showing common functions of a deque*/

#include
#include

#define MAX 100

double ar[MAX];
int front,rear;
class ArrayDeque
{
public:
ArrayDeque()
{
front=-1;
rear=-1;
}

void insertRear(double x)
{
if(front==-1 && rear==-1)
{
ar[++rear]=x;
front++;
}
else
{
ar[++rear]=x;
}
}

void disp()
{
for(int i=front;i<=rear;i++)
{
cout<<" "< }
}

int delFront()
{
int temp;
if(front==rear)
{cout<<"List is empty";
return 0;
}
else
{
temp=ar[front];
front++;
return temp;
}
}

int delRear()
{
int t;
if(front==rear)
{cout<<"List is empty";
return 0;
}
else
{
t=ar[rear];
rear--;
return t;
}
}
  
};

2) DequeStack

#include
#include
#include
#define MAX 100

double ar[MAX];
int top;
class DequeStack
{
public:
DequeStack()
{
top=-1;
}

void push(double x)
{
ar[++top]=x;
}

void disp()
{
for(int i=top;i>=0;i--)
{
cout<<" "< }
}

int pop()
{
int temp;
if(top==-1)
{cout<<"List is empty";
return 0;
}
else
{
temp=ar[top];
top--;
return temp;
}
}

};

3) WidgetManager.h

#include
#include

class WidgetManager
{
double amount;
public:
double buyWidgets(double cost, int numToBuy)
{
return numToBuy * cost;
}

double sellWidgets(double cost, int numToSell)
{
return numToSell * cost;
}

};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote