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

You operate several hot dog stands distributed throughout town.Define a class na

ID: 3609778 • Letter: Y

Question

You operate several hot dog stands distributed throughout town.Define a class named HotDogStand that has a member variable for thehot dog stand's ID number and a member variable for how many hotdogs the stand has sold that day. Create a constructor that allowsa user of the class to initialize both values.
Also create a method named justSold that increments the number ofhot dogs the stand has sold by one. The idea is that this methodwill be invoked each time the stand sells a hot dog so that we cantrack the total number of hot dogs sold by the stand. Add anothermethod that returns the number of hot dogs sold.

Finally, add a static variable that tracks the total number ofhotdogs sold by all hot dog stands and a static method that returnsthe value in this variable.

Write a main method to test your class with at least three hot dogstands that each sell a variety of hot dogs.

so for I had this

class HotDogStand
{
public:
    HotDogStand();
    HotDogStand(int newID, int newNnumSold);
    int GetID();
    void SetID(int);
    void JustSold();
    void JustSold(int count){NSold += count;};
    int GetNumSold(){return NSold;};
    int GetTotalSold(){return TotalSold +=NSold;};
private:
    int NID,NSold, TotalSold, count;

};

int main()
{



HotDogStand s1(1,0);
HotDogStand s2(2,0);
HotDogStand s3(3,0);
HotDogStand s4;


s1.JustSold();
s2.JustSold();
s1.JustSold();
s4.JustSold();


cout << "Stand " << s1.GetID() << " sold "<< s1.GetNumSold() << endl;
cout << "Stand " << s2.GetID() << " sold "<< s2.GetNumSold() << endl;
cout << "Stand " << s3.GetID() << " sold "<< s3.GetNumSold() << endl;
cout << "Stand " << s4.GetID() << " sold "<< s4.GetNumSold() << endl;

cout << "Total sold = " << s1.GetTotalSold()<< endl;
cout << endl;


s3.JustSold();
s1.JustSold();
s2.JustSold(5);
s1.SetID (99);
s4.SetID(4);

cout << "Stand " << s1.GetID() << " sold "<< s1.GetNumSold() << endl;
cout << "Stand " << s2.GetID() << " sold "<< s2.GetNumSold() << endl;
cout << "Stand " << s3.GetID() << " sold "<< s3.GetNumSold() << endl;
cout << "Stand " << s4.GetID() << " sold "<< s4.GetNumSold() << endl;

cout << "Total sold = " << s1.GetTotalSold()<< endl;
cout << endl;


    system("pause");
    return 0;

}

int HotDogStand::GetID() {
    return NID;
}
void HotDogStand::SetID(int newID){
    NID= newID;
}


HotDogStand::HotDogStand()
{
    NID = 0;
    NSold = 0;
}

HotDogStand::HotDogStand(int newID, int newNnumSold)
{
   NID = newID;
   NSold = newNnumSold;
}
void HotDogStand::JustSold()
{
    NSold++;
}

Stand 1 sold 2
Stand 2 sold 1
Stand 3 sold 0
Stand 0 sold 1
Total sold = -858993458

Stand 99 sold 3
Stand 2 sold 6
Stand 3 sold 1
Stand 4 sold 1
Total sold = -858993455

Press any key to continue . .

how can I fix the total stand

Explanation / Answer

You did not set any value for TotalSold, so it istaking some garbage value and adding NSold to that garbagevalue. To fix the TotalSold, assign zero to theTotalSold in the constructors asbelow:HotDogStand::HotDogStand() {     NID = 0;     NSold = 0;     TotalSold=0; } HotDogStand::HotDogStand(int newID, int newNnumSold) {    NID = newID;    NSold = newNnumSold; TotalSold=0; }

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