Create an Inventory class with the following properties: InvNumber: A string use
ID: 662676 • Letter: C
Question
Create an Inventory class with the following properties:
InvNumber: A string used to hold an inventory number. Each item in the inventory should have a unique inventory number.
Description: A string that holds a brief description of the item.
Cost: A decimal value that holds the amount that the retail store paid for the item.
Retail: A decimal value that holds the retail price of the item.
OnHand: An integer value that holds the number of items on hand. This value cannot be less than 0.
Create constructors, destructors, accessors, mutators, and custom methods as needed
Create a class that manages a collection of Inventory class objects. The manager class searches, inserts, removes, updates inventory records. The manager class also reads the collection from a file and writes the collection to a file. Create constructors, destructors, accessors, mutators, and custom methods.as needed..
Create a cash register class for a retail store. What are the class
Explanation / Answer
Below is the code which gets data from the user in Inventory class and stores and process in the main class.
#include "Inventory.h"
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
String InvNumber,
Description;
double cost,OnHold,
Retail;
cout << "Enter the Item Number: ";
cin >> InvNumber;
while (InvNumber != 0)
{
cout << "Error - Enter a positive and Unique value for the Item Number: ";
cin >> InvNumber;
}
cout << "Enter the Description: ";
cin >> Description;
cout << "Enter the Retail price of the item: ";
cin >> Retail;
while (Retail < 0)
{
cout << "Error - Enter a positive value for the Retail of the item: ";
cin >> Retail;
}
cout << "Enter the Cost of the item: $";
cin >> cost;
while (cost < 0)
{
cout << "Error - Enter a positive value for the Cost of the item: $";
cin >> cost;
}
cout << "Enter the Number of the item in hand: $";
cin >> OnHold;
while (OnHold < 0)
{
cout << "Error - Enter a positive value for the numberof the item onHold: $";
cin >> onHold;
}
cout << "----------------------------------" << endl;
Inventory inventoryA(InvNumber, Description, cost,Retail,OnHold);
Retail = inventoryA.getRetail();
InvNumber = inventoryA.getInvNumber();
cost = inventoryA.getCost();
Description = inventoryA.getDescription();
> cout << "Item Number: " << InvNumber << endl;
cout << "Description: " << Description << endl;
cout << "Cost: $" << cost << endl;
cout << "Total Cost: $" << fixed << setprecision(2) << Retail << endl << endl;
return 0;
}
class Inventory
{
private:
String InvNumber,Description;
double cost,Retail, OnHold;
public:
Inventory()
{
InvNumber = 0;
Description = 0;
cost = 0;
Retail = 0;
> }
Inventory(String InvNumber, String Description, double cost, double onHold)
{
InvNumber = getInvNumber();
Description = getDescription();
cost = getCost();
setRetail(Description, cost);
> }
void setInvNumber(int)
{
InvNumber = InvNumber;
}
void setDescription(String)
{
Description = Description;
}
void setCost(double)
{
cost = cost;
}
void setRetail(double)
{
Retail = retail;
}
void OnHold(double)
{
> }
String getInvNumber()
{
return InvNumber;
}
String getDescription()
{
return Description;
}
double getCost()
{
return cost;
}
double getRetail()
{
return Retail;
}
double getOnHold()
{
return OnHold;
}
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.