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

This is for C++ language: Please help figure this out as I am having a hard time

ID: 3911725 • Letter: T

Question

This is for C++ language: Please help figure this out as I am having a hard time just setting up my class, main.cpp and .h file in Visual Studios 2017.

ional Requirements: Design an inventory class that can hold data for Joseph's Computer Repair Programming Requirements Design an inventory class my friend's computer repair and sales business. embe vate positive int string that holds the item description f25 characters) string that holds last name of the customer (25 chars) string that holds customer's phone numher 11 chars) float >-0 that holds the quoted repair price custPhone float >-0that holds the number of hours of labor embe escription (all ubl Default Constructor sets all the member variables to 0 or to"" Constructor #2 variables. itemDesc etc... The function should copy these values to the appropriate accepts accepts an integer argument that is copied to the itemNumbermember - (if -25 then EXIT_FAILURE) accepts a string argument that is copied to the custlastName member[if len-25 then accepts a string argument that is copied to the custPhone member (if len-11 then EXIT_FAILURE) accepts a float argument that is copied to the priceQuoted member (if

Explanation / Answer

Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you

inventory.h
-------

#ifndef inventory_h
#define inventory_h

class inventory
{
private:
int itemNumber;
char itemDesc[25];
char custLastName[25];
char custPhone[11];
float priceQuoted;
float hoursWorked;

public:
inventory();
inventory(int inum, char *desc, char *lname, char *phone, float quoted, float hours);
void setItemNumber(int inum);
void setItemDesc(char *desc);
void setCustLastName(char *lname);
void setCustPhone(char *phone);
void setPriceQuoted(float price);
void setHoursWorked(float hours);

int getItemNumber();
char* getItemDesc();
char* getCustLastName();
char* getCustPhone();
float getPriceQuoted();
float getHoursWorked();
};

#endif /* inventory_h */


inventory.cpp
---------

#include "inventory.h"
#include <cstring>
#include <iostream>
#include <cstdlib>
using namespace std;

inventory::inventory(){
itemNumber = 0;
strcpy(itemDesc, "");
strcpy(custLastName, "");
strcpy(custPhone, "");
priceQuoted = 0;
hoursWorked = 0;

}
inventory::inventory(int inum, char *desc, char *lname, char *phone, float quoted, float hours){
setItemNumber(inum);
setItemDesc(desc);
setCustLastName(lname);
setCustPhone(phone);
setPriceQuoted(quoted);
setHoursWorked(hours);
}
void inventory::setItemNumber(int inum){
if(inum < 0)
{
cout << "Invalid item number " << inum << endl;
exit(EXIT_FAILURE);
}
itemNumber = inum;

}
void inventory::setItemDesc(char *desc){
if(strlen(desc) >= 25){
cout << "Item descrption should be less than 25 characters "<< endl;
exit(EXIT_FAILURE);
}
strcpy(itemDesc, desc);

}
void inventory::setCustLastName(char *lname){
if(strlen(lname) >= 25){
cout << "Customer last name should be less than 25 characters "<< endl;
exit(EXIT_FAILURE);
}
strcpy(custLastName, lname);

}
void inventory::setCustPhone(char *phone){
if(strlen(phone) >= 25){
cout << "Phone should be less than 11 characters "<< endl;
exit(EXIT_FAILURE);
}
strcpy(custPhone, phone);

}
void inventory::setPriceQuoted(float price){
if(price < 0){
cout << "Price quoted can not be negative"<< endl;
exit(EXIT_FAILURE);
}
priceQuoted = price;

}
void inventory::setHoursWorked(float hours){
if(hours < 0){
cout << "Hours worked can not be negative"<< endl;
exit(EXIT_FAILURE);
}
hoursWorked = hours;
}

int inventory::getItemNumber(){
return itemNumber;
}
char* inventory::getItemDesc(){
return itemDesc;
}
char* inventory::getCustLastName(){
return custLastName;
}
char* inventory::getCustPhone(){
return custPhone;
}
float inventory::getPriceQuoted(){
return priceQuoted;
}
float inventory::getHoursWorked(){
return hoursWorked;
}


main.cpp
------
#include <iostream>
#include <string>
#include <iomanip>
#include "inventory.h"
using namespace std;
int main(){
inventory repairs[5];
char desc[50], name[50], phone[50];
int inum;
float price, hours;

for(int i = 0; i < 5; i++){
cout << "Enter details for item " << i+1 << endl;
cout << "Enter item number: ";
cin >> inum;
repairs[i].setItemNumber(inum);

cout << "Enter description: ";
cin >> desc;
repairs[i].setItemDesc(desc);

cout << "Enter customer last name: ";
cin >> name;
repairs[i].setCustLastName(name);

cout << "Enter phone number: ";
cin >> phone;
repairs[i].setCustPhone(phone);

cout << "Enter price quoted: ";
cin >> price;
repairs[i].setPriceQuoted(price);

cout << "Enter hours worked: ";
cin >> hours;
repairs[i].setHoursWorked(hours);
}


float totalHours = 0;
cout << fixed << setprecision(2);
for(int i = 0; i < 5; i++){
cout << "Item: " << repairs[i].getItemNumber() << endl;
cout << "Desc: " << repairs[i].getItemDesc() << endl;
cout << "Cust: " << repairs[i].getCustLastName() << endl;
cout << "Phone: " << repairs[i].getCustPhone() << endl;
cout << "Quote: $" << repairs[i].getPriceQuoted()<< endl;
cout << "Hours: " << repairs[i].getHoursWorked() << endl << endl;

totalHours += repairs[i].getHoursWorked();

}

cout << "Total hours worked on all repairs is " << totalHours << endl;

system("pause");
}

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