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

PLEASE HELP c++ Having trouble answering these two question an experts out there

ID: 662889 • Letter: P

Question

PLEASE HELP c++

Having trouble answering these two question an experts out there that might be able to help

Help with c++ problem

1. Create a Retail Store Class. The class has a cash register, a collection of inventory objects. It sells various items in its inventory to its customers, it purchases more quantities of items in stock from its suppliers; it purchases quantities of new items from its suppliers. It computes its profit or loss by subtracting the cost of its  inventory from its retail sales. The retail store reads and writes its inventory collection, its sales to customers records and it purchases from wholesalers records to and from files.

2. Write a program that simulates the operations of a retail store. The program reads commands from a file. The commands tell the store to purchase inventory items from whole sellers, sell items to customers, displays the stores profit/loss position, read the store's records from files, write the store's records to files.

here are the classes for the problems

//Header file declaration
//Inventory.h
#ifndef INVENTORY_H
#define INVENTORY_H
#include<iostream>
#include<string>
using namespace std;
class Inventory
{
private:
   //private member variables of class
   string InvNumber;
   string Description;
   double cost;
   double Retail;
   double OnHand;
public:
   //Default constructor
   Inventory();
   //Parameterized constructor
   Inventory(string InvNumber, string Description, double cost, double Retail,double onHand);
  
   //Mutator methods
   void setInvNumber(string InvNumber);
   void setDescription(string Description);
   void setCost(double cost);
   void setRetail(double Retail);
  
   void setOnHand(double onHand);
  

   //Accessor methods
   string getInvNumber();
   string getDescription();
   double getCost();
   double getRetail();
   double getOnHand();
  
};
#endif INVENTORY_H
--------------------------------------------------------------------------------------------------------------------

//Header file declaration
//Inventory.cpp
#include<string>
#include "Inventory.h"
//default constructor
Inventory::Inventory()
{
   InvNumber = "";
   Description = "";
   cost = 0;
   Retail = 0;
  > }
//parameterized constructor
Inventory::Inventory(string InvNumber, string Description,
                   double cost, double Retail,double onHand)
{
   //calling mutator methods to set values
   setInvNumber(InvNumber);
   setDescription(Description);
   setCost(cost);
   setRetail(Retail);
   setOnHand(onHand);

}

//Mutator methods defintions
void Inventory::setInvNumber(string InvNumber)
{
   this->InvNumber = InvNumber;
}
void Inventory::setDescription(string Description)
{
   this->Description = Description;
}
void Inventory::setCost(double cost)
{
   this->cost = cost;
}
void Inventory::setRetail(double Retail)
{
   this->Retail = Retail;
}
void Inventory::setOnHand(double onHand)
{
   this->OnHand= onHand;
}
//Accessor methods defintions
string Inventory::getInvNumber()
{
   return InvNumber;
}
string Inventory::getDescription()
{
   return Description;
}
double Inventory::getCost()
{
   return cost;
}
double Inventory::getRetail()
{
   return Retail;
}
double Inventory::getOnHand()
{
   return OnHand;
}
----------------------------------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include "Inventory.h"
using namespace std;

int main()
{
   string InvNumber;
   string Description;
   double cost;
   double OnHand;
   double Retail;

   cout << "Enter 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 >> OnHand;
   while (OnHand < 0)
   {
       cout << "Error - Enter a positive value for the numberof the item OnHand: ";
       cin >> OnHand;
   }

   cout << "----------------------------------" << endl;

   Inventory inventoryA(InvNumber, Description, cost,Retail,OnHand);
   cout << "Item Number: " << inventoryA.getInvNumber() << endl;
   cout << "Description: " << inventoryA.getDescription() << endl;
   cout << "Cost: $" <<inventoryA.getCost() << endl;
   cout << "Total Cost: $" <<inventoryA.getCost()*inventoryA.getOnHand() << endl << endl;


   system("pause");
   return 0;
}

#include<iostream>
#include<fstream> //for files reading/writing
#include<vector> //for vector class
#include "Inventory.h" //include header file
using namespace std;
//main method
void main()
{
   //vector class's object
   vector<Inventory*> records;
   // variables
   string invNo;
   string itemDes;
   double retail;
   double cost;
   double onHand;
   double totalCost;
   int totalRecords=0;
   int pos;
   bool found=false;
   char fileName[50];
   int ch;
   //file objects
   ifstream infile;
   ofstream myfile;
   while(true)
   {

       cout<<"1. Insert inventory Record ";
       cout<<"2. Remove inventory Record ";
       cout<<"3. Update inventory Record ";
       cout<<"4. Print inventory Cart ";
       cout<<"5. Write inventory Records to file ";
       cout<<"6. Read inventory Records to file ";
       cout<<"7. Exit ";
       cout<<"Enter your choice: ";
       cin>>ch;
       switch(ch)
       {
       case 1:
           cout<<"Enter inventory item Number: ";
           while(true)
           {
               cin>>invNo;
               found=false;
               for(int i=0; i<records.size(); i++)
               {
                   if(records[i]->getInvNumber()==invNo)
                   {
                       found=true;
                       break;
                   }

               }

               if(found)

               {

                   cout<<"The item number already exist in cart! ";

                   cout<<"Re Enter inventory Item Number: ";

               }

               else

               {

                   break;

               }

           }

           cout<<"Enter Item Description: ";

           cin>>itemDes;

           cout<<"Enter retail: ";

           cin>>retail;

           cout<<"Enter Cost: ";

           cin>>cost;

           cout<<"Enter on hand price: ";

           cin>>onHand;

           records.push_back(new Inventory(invNo,itemDes,retail,cost,onHand));

           cout<<"Item added to cart successfully! ";

           break;

       case 2:

           cout<<"Enter inventory Item Number to Remove: ";

           cin>>invNo;

           found=false;

           for(int i=0; i<records.size(); i++)

           {

               if(records[i]->getInvNumber()==invNo)

               {

                   pos=i;

                   found=true;

                   break;

               }

           }

           if(found)

           {

               records.erase(records.begin()+pos);

               cout<<"Item deleted successfully from the cart! ";

           }

           else

           {

               cout<<"Entered Item Number not found! ";

           }

           break;

       case 3:

           cout<<"Enter Item Number to Update: ";

           cin>>invNo;

           found=false;

           for(int i=0; i<records.size(); i++)

           {

               if(records[i]->getInvNumber()==invNo)

               {

                   pos=i;

                   found=true;

                   break;

               }

           }
           if(found)

           {

               cout<<"Re enter retail: ";

               cin>>retail;

               records[pos]->setRetail(retail);

               cout<<"Item Details Updated successfully! ";
           }

       else

           {

               cout<<"Entered Item Number not found! ";

           }
           break;
       case 4:

           totalCost=0;

           if(records.size()==0)

           {

               cout<<"Cart is Empty. No Items to Display! ";

           }

           else

           {

               cout<<"--------------------------------------------------------------------------- ";

               cout<<"No Item_Description Cost Retail_Cost On_hand TotalCost ";

               cout<<"--------------------------------------------------------------------------- ";

               for(int i=0; i<records.size(); i++)

               {

                   cout<<records[i]->getInvNumber()<<" "<<records[i]->getDescription()<<" "<<records[i]->getRetail()<<" "

                       <<records[i]->getCost()<<" "<<records[i]->getOnHand()<<" "<<records[i]->getCost()<<" ";

                   totalCost = totalCost+ records[i]->getCost();

               }

               cout<<"--------------------------------------------------------------------------- ";

               cout<<"Total Cost "<<totalCost<<"$"<<endl;

               cout<<"--------------------------------------------------------------------------- ";

           }

           break;

       case 5:

           cout<<"Enter file name to write inventory data : ";

           cin>>fileName;

           if(records.size()==0)

           {

               cout<<"Cart is empty! ";

           }

           else

           {

               myfile.open(fileName);

               for(int i=0; i<records.size(); i++)

               {

                   myfile<<records[i]->getInvNumber()<<" "<<records[i]->getDescription()<<" "<<records[i]->getRetail()<<" "

                       <<records[i]->getCost()<<" "<<records[i]->getCost()<<" ";

               }  

               myfile.close();

               cout<<"Cart details written to "<<fileName<<" successfully! ";

           }

           break;

       case 6:

           cout<<"Enter file name to read inventory data : ";

           cin>>fileName;

           infile.open(fileName);

           while (!infile.eof())

           {

               infile >> invNo;

               infile >> itemDes;

               infile >> retail;

               infile >> cost;

               cout<<invNo<<endl;

               cout<<itemDes<<endl;

               cout<<retail<<endl;

               cout<<cost<<endl;

               cout<<onHand<<endl;

               records.push_back(new Inventory(invNo,itemDes,retail,cost,onHand));

           }

           records.pop_back();

           cout<<"Item details added to cart succssfully! ";  

           infile.close();
           break;
       case 7:
           break;
       default:
           cout<<"Invalid choice! ";
       }
       if(ch==7)
           break;
   }
   system("PAUSE");
}

Here is the CashRegister class

//CashRegister.cpp file

//include header file CashRegister.h into the CashRegister.cpp
#include"CashRegister.h"
CashRegister::CashRegister(double price, double profit, double subtotal, double tax)
{
   this->price=price;
   this->tax = 0.06; //6 percent of tax on items
   //call parent class getCost and getOnHand to calculate the subtotal of items
   this->subtotal=getCost()*getOnHand();
   this->profit=profit

}
double CashRegister::getItemPrice() const
{
   return price;
}

double CashRegister::getTax() const
{
   return tax;
}

double CashRegister::getProfit() const
{
   return profit;
}

double CashRegister::getSubtotal() const
{
   return subtotal;
}
------------------------------------------------------

question 5 is basically a simulator that will combine all these codes together

Explanation / Answer

1)

caaling cashRegister methods by creating new object

#include 'CashRegister.h'
CashRegister::CashRegister(){

}
void main(){
CashRegister CR(12.00,3,24,4);
cout<<b.getItemPrice();
cout<<b.getTax();
cout<<b.getProfit();
cout<<b.getSubtotal();
}

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