Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the Store class, complete the function definition for SetNumSold ( ) with the integer parameter customNumSold. Ex: If the input is 4 1 6

In the Store class, complete the function definition for SetNumSold() with the integer parameter customNumSold.
Ex: If the input is 4160, then the output is:
Years open: 41
Number of items sold: 60
#include
using namespace std;
class Store {
public:
void SetYearsOpen(int customYearsOpen);
void SetNumSold(int customNumSold);
int GetYearsOpen() const;
int GetNumSold() const;
private:
int yearsOpen;
int numSold;
};
void Store::SetYearsOpen(int customYearsOpen){
yearsOpen = customYearsOpen;
}
void Store::SetNumSold(int customNumSold){
{
numSold = customNumSold;
}
int Store::GetYearsOpen() const {
return yearsOpen;
}
int Store::GetNumSold() const {
return numSold;
}
int main(){
Store store1;
int inputYearsOpen;
int inputNumSold;
cin >> inputYearsOpen;
cin >> inputNumSold;
store1.SetYearsOpen(inputYearsOpen);
store1.SetNumSold(inputNumSold);
cout << "Years open: "<< store1.GetYearsOpen()<< endl;
cout << "Number of items sold: "<< store1.GetNumSold()<< endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions