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

Ok, so i am getting this program, the only thing i need to run now would be the

ID: 3647020 • Letter: O

Question

Ok, so i am getting this program, the only thing i need to run now would be the inventory.h file with all the function declared, can you Chegg professionals help me please :D




This is the inventory.cpp file...
I need the inventory.h file...and possible the client.cpp
// ProjectCLIENT - client code to serve as a driver program for testing the Inventory class implementation
//
// Additional files needed to compile this multifile programming project:
// Inventory.h -- contains Inventory class specification and inline functions
// Inventory.cpp -- contains Inventory class function definitions
// client.cpp -- this file used to create new inventory class objects and to test a few operation

#include <iostream>
#include <iomanip>
#include "Inventory.h"
using namespace std;

int main()
{
cout << fixed << showpoint << setprecision(2);

cout<<"This is a driver program to test the Inventory class implementation. ";
cout<<"Three Inventory class objects are defined here and used to test access ";
cout<<"to the object's data members and procedures through the interface provided ";
cout<<"by the Inventory class member implementation. ";


// Demonstrate the default constructor and the "get" functions
Inventory stockItem1;
cout << "(1)Demonstrating the default constructor. ";
cout << ""get" functons used to display default values in the stockItem1 object... ";
cout<<"****************************************************** ";
cout << "Item number: " << stockItem1.getItemID() << endl;
cout << "Quantity : " << stockItem1.getItemQuantity() << endl;
cout << "Cost : $" << stockItem1.getItemCost() << endl;


// Now demonstrate the overloaded constructor and the "get" functions
Inventory stockItem2(124, 12, 84.95);
cout << " (2)Demonstrating the overloaded constructor. ";
cout << ""get" functons used to display values in the stockItem2 object... ";
cout<<"****************************************************** ";
cout << "Item number: " << stockItem2.getItemID() << endl;
cout << "Quantity : " << stockItem2.getItemQuantity() << endl;
cout << "Cost : $" << stockItem2.getItemCost() << endl;


// Now demonstrate the member "set" functions used to update or change an objects values
stockItem2.setItemID(243);
stockItem2.setItemQuantity(50);
stockItem2.setItemCost(9.50);

cout << " (3)Demonstrating the "set" functions used to update the stockItem2 object. ";
cout << ""get" functons used to display values in this object ... ";
cout<<"****************************************************** ";
cout << "Item number: " << stockItem2.getItemID() << endl;
cout << "Quantity : " << stockItem2.getItemQuantity() << endl;
cout << "Cost : $" << stockItem2.getItemCost() << endl;
cout << "Total Cost in inventory : $" << stockItem2.getTotalCost() << endl;


// Now demonstrate the getItemDetails and showItemDetails function
Inventory stockItem3;

cout << " (4)Demonstrating the "getItemDetails" function used to input item details ";
cout <<"into a new stockItem3 object ... ";
cout<<"****************************************************** ";
stockItem3.getItemDetails();

cout << " (5)Demonstrating the "showItemDetails" function used to display values. ";
cout << "in this object ... ";
cout<<"****************************************************** ";
stockItem3.showItemDetails();
cout<<"******************************************************* ";

//system("PAUSE");
return 0;
}

Explanation / Answer

#ifndef INVENTORY_H #define INVENTORY_H class Inventory { private: int itemNumber; int quantity; double cost; double totalCost; public: // Default constructor Inventory() { itemNumber = quantity = cost = totalCost = 0; } // Overloaded constructor Inventory(int, int, double); // Defined in Inventory.cpp // Mutators (i.e., "set" functions) defined in Inventory.cpp void setItemNumber(int); void setQuantity(int); void setCost(double); // setTotalCost calculates the total cost // and stores the result in the totalCost member void setTotalCost() { totalCost = cost * quantity; } // Accessors (i.e., "get" functions) int getItemNumber() { return itemNumber; } int getQuantity() { return quantity; } double getCost() { return cost; } double getTotalCost() { return totalCost; } // Input validation functions bool validInt(int); bool validFloat(double); }; #endif // This is the inventory.cpp file. // It contains the Inventory class function definitions. #include #include "Inventory.h" using namespace std; //************************************************************ // Overloaded constructor // Accepts arguments to be stored in each member variable. //************************************************************ Inventory::Inventory(int in, int q, double c) { setItemNumber(in); setQuantity(q); setCost(c); setTotalCost(); } //************************************************************ // setItemNumber accepts an argument to be stored in item number. //************************************************************ void Inventory::setItemNumber(int in) { while (!validInt(in)) { cout > in; } itemNumber = in; } //************************************************************ // setQuantity accepts an argument to be stored in quantity. //************************************************************ void Inventory::setQuantity(int q) { while (!validInt(q)) { cout > q; } quantity = q; } //************************************************************ // setCost accepts an argument to be stored in cost. //************************************************************ void Inventory::setCost(double c) { while (!validInt(c)) { cout > c; } cost = c; } //************************************************************ // The validInt member tests its integer argument to see // if it is negative. If the argument is negative, the function // returns false. Otherwise, the function returns true. //************************************************************ bool Inventory::validInt(int value) { if (value < 0) // the value is negative so it is NOT valid return false; else // the integer value is valid return true; } //************************************************************ // The validFloat member tests its floating-point argument to see // if it is negative. If the argument is negative, the function // returns false. Otherwise, the function returns true. //************************************************************ bool Inventory::validFloat(double value) { if (value < 0) // the value is negative so it is NOT valid return false; else // the floating-point value is valid return true; }
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