Question: #include #include using namespace std; #define MAX 5 class inventory { private : // item number for inventory int itemNumber; // string that holds the
#include#include using namespace std; #define MAX 5 class inventory { private: // item number for inventory int itemNumber; // string that holds the item description (< 25 characters) string itemDesc; // string that holds last name of the customer (<25 chars) string custlastname;>=0 that holds the quoted repair price float priceQuoted; // float >=0 that holds the number of hours of labor float hoursWorked; public: // Default constructor inventory(){ itemNumber = 0; itemDesc = ""; custLastName = ""; custPhone = ""; priceQuoted = 0; hoursWorked = 0; } // parameterized constructor inventory( int ino, string iDesc, string name, string phone, float price, float hrs ){ itemNumber = ino; itemDesc = iDesc; custLastName = name; custPhone = phone; priceQuoted = price; hoursWorked = hrs; } // setter for class // accepts an integer argument that is copied to the itemNumber member - (if <0 then exit_failure) void setItemNumber(int ino){ if ( ino < 0 ) exit( EXIT_FAILURE ); itemNumber = ino; } // accepts a string argument that is copied to the itemDesc member (if len>=25 then EXIT_FAILURE) void setitemDesc(string iDesc){ if ( iDesc.size() > 25 ) exit( EXIT_FAILURE ); itemDesc = iDesc; } // accepts a string argument that is copied to the custLastName member(if len>=25 then EXIT_FAILURE) void setCustLastName(string name){ if ( name.size() > 25 ) exit( EXIT_FAILURE ); custLastName = name; } // accepts a string argument that is copied to the custPhone member (if len>=11 then EXIT_FAILURE) void setCustPhone(string phone){ if ( phone.size() > 11 ) exit( EXIT_FAILURE ); custPhone = phone; } // accepts a float argument that is copied to the priceQuoted member (if <0 then exit_failure) void setPriceQuoted(float price){ if ( price < 0 ) exit( EXIT_FAILURE ); priceQuoted = price; } // accepts a float argument that is copied to the hoursWorked member (if<0 then exit_failure) void setHoursWorked(float hrs){ if ( hrs < 0 ) exit( EXIT_FAILURE ); hoursWorked = hrs; } // getters int getItemNumber(){ return itemNumber; } string getItemDesc(){ return itemDesc; } string getCustLastName(){ return custLastName; } string getCustPhone(){ return custPhone; } float getPriceQuoted(){ return priceQuoted; } float getHoursWorked(){ return hoursWorked; } }; int main() { inventory inv[MAX]; int ino; string name, desc, phone; float price, hrs, total_time = 0; cout << "Joseph's Computer Repair" << endl << endl; for ( int i = 0; i < MAX; i++ ){ cout << "Enter Data for Item " << (i + 1) << endl; cout << left << setw(30) << "Enter item no : "; cin >> ino; inv[i].setItemNumber(ino); cin.ignore(); cout << left << setw(30) << "Enter item description : "; getline(cin,desc); inv[i].setitemDesc(desc); cout << left << setw(30) << "Enter last name : "; cin >> name; inv[i].setCustLastName(name); cout << left << setw(30) << "Enter phone : "; cin >> phone; inv[i].setCustPhone(phone); cout << left << setw(30) << "Enter quoted price : "; cin >> price; inv[i].setPriceQuoted(price); cout << left << setw(30) << "Enter hrs worked : "; cin >> hrs; inv[i].setHoursWorked(hrs); cout << endl; } for ( int i = 0; i < MAX; i++ ){ cout << left << setw(30) << "Item no : " << inv[i].getItemNumber() << endl ; cout << left << setw(30) << "Desc : " << inv[i].getItemDesc() << endl; cout << left << setw(30) << "Cust : " << inv[i].getCustLastName() << endl; cout << left << setw(30) << "Phone : " << inv[i].getCustPhone() << endl; cout << left << setw(30) << "Quote : "<< "$" << inv[i].getPriceQuoted() << endl; cout << left << setw(30) << "Hours : " << inv[i].getHoursWorked() << endl; total_time += inv[i].getHoursWorked(); cout << endl; } cout << "Total hours worked on all repairs = " << total_time << endl; return 0; }
how would separate this code using header files
i need main.cpp
inventory.h and inventory.cpp
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
