Question: In the Business class, complete the function definition for SetYearsOpen ( ) with the integer parameter newYearsOpen. Ex: If the input is 1 5 6

In the Business class, complete the function definition for SetYearsOpen() with the integer parameter newYearsOpen.
Ex: If the input is 15610445, then the output is:
Items in stock: 156
Number of items sold: 104
Years open: 45
#include
using namespace std;
class Business {
public:
void SetNumStock(int newNumStock);
void SetNumSold(int newNumSold);
void SetYearsOpen(int newYearsOpen);
int GetNumStock() const;
int GetNumSold() const;
int GetYearsOpen() const;
private:
int numStock;
int numSold;
int yearsOpen;
};
void Business::SetNumStock(int newNumStock){
numStock = newNumStock;
}
void Business::SetNumSold(int newNumSold){
numSold = newNumSold;
}
/* Your code goes here */
{
yearsOpen = newYearsOpen;
}
int Business::GetNumStock() const {
return numStock;
}
int Business::GetNumSold() const {
return numSold;
}
int Business::GetYearsOpen() const {
return yearsOpen;
}
int main(){
Business business1;
int userNumStock;
int userNumSold;
int userYearsOpen;
cin >> userNumStock;
cin >> userNumSold;
cin >> userYearsOpen;
business1.SetNumStock(userNumStock);
business1.SetNumSold(userNumSold);
business1.SetYearsOpen(userYearsOpen);
cout << "Items in stock: "<< business1.GetNumStock()<< endl;
cout << "Number of items sold: "<< business1.GetNumSold()<< endl;
cout << "Years open: "<< business1.GetYearsOpen()<< endl;
return 0;
} in c++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!