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

class cashRegister { public : int getCurrentBalance() const; void acceptAmount (

ID: 3558198 • Letter: C

Question

class cashRegister
{
public :
   int getCurrentBalance() const;
   void acceptAmount ( int amountIn );
   cashRegister( int cashIn = 500 );
private:
   int cashOnHand;
}; // end class definition of cashRegister

class dispenserType
{
public :
   int getNoOfItems() const;
   int getCost() const;   
   void makeSale();
   dispenserType(int setNoOfItems =50, int setCost =50);

private:
   int numberOfItems;
   int cost;
}; // end class definition of dispenserType
//------------------------------------------------

#include<iostream>
using namespace std;

int cashRegister::getCurrentBalance () const
{
   return cashOnHand;
}; // end function getCurrentBalance

void cashRegister::acceptAmount( int amountIn )
{
   cashOnHand = cashOnHand + amountIn;
}; // end function acceptAmount

cashRegister::cashRegister( int cashIn )
{
   if ( cashIn >= 0 )
       cashOnHand = cashIn;
   else
       cashOnHand = 500;
}; // end constructor cashRegister

int dispenserType::getNoOfItems() const
{
   return cost;
}; // end function getCost

void dispenserType::makeSale()
{
   numberOfItems;
}; // end function makesale

dispenserType::dispenserType (int setNoOfItems, int setCost)
{
   if ( setNoOfItems >= 0 )
       numberOfItems = setNoOfItems;
   else
       numberOfItems = 50;
   if ( setCost > 0 )
       cost = setCost;
   else
       cost = 50;
}; // end constructor with parameters
//----------------------------------------------------
// Main program

#include<iostream>
using namespace std;

void showSelection();
void sellProduct(dispenserType & product, cashRegister & pCounter);

int main() //function main begins program execution
{
   // instantiate objects
   cashRegister counter;
   dispenserType juice( 100, 50 );
   dispenserType chips( 100, 65 );
   dispenserType soda( 75, 45 );
   dispenserType chocolatebar( 100, 85 );

   int choice;

   showSelection();
   cin >> choice;

   while ( choice != 9 )
   {
       switch( choice )
       {
           case 1 : sellProduct( juice, counter );
                       break;
           case 2 : sellProduct( chips, counter );
                       break;
           case 3 : sellProduct( soda, counter );
                       break;
           case 4 : sellProduct( chocolatebar, counter );
                       break;
           default : cout << " Invalid selection.";
       }; // end switch
       showSelection();
       cin >> choice;
   }; // end while

   return 0;   // indicate program executed successfully
               // end of function, main
};

void showSelection()
{
   cout << " *** Welcome to The Shop ***";
   cout << " l for Juice";
   cout << " 2 for Chips";
   cout << " 3 for Soda";
   cout << " 4 for Chocolatebar";
   cout << " 9 for Exit";
   cout << " Enter your item choice : ";
}; // end function showSelection

void sellProduct(dispenserType & product, cashRegister & pCounter)
{
   int amount;
   int amount2;

   if ( product.getNoOfItems() > 0 )
   {
       amount = 0;
       do
       {
           // find out the amount to deposit
           amount2 = product.getCost() - amount;
           // prompt and read the amount from user
           cout << " Please deposit "
                   << amount2
                   << "sents : ";
           cin >> amount2;

           // add the amount to total amount
           amount += amount2;

           // print the message for additional amount
           if ( amount < product.getCost() )
               cout <<" The amount of money is not enough for the item<s>.";
       } while ( amount < product.getCost() );

       pCounter.acceptAmount ( amount );
       product.makeSale();
       cout << " Collect your items at"
           << "the bottom and enjoy. ";
extern void func(void);
system("pause");
  
   }; // end if
}// end function sellProduct

___________________________________________

I did this program in C++ for selling products but it keeps giving me these two errors

I appreciate your help ...

Explanation / Answer

Just these changes from line no 46:

//what u did

int dispenserType::getNoOfItems() const
{
return numberOfItems;
}; // end function getCost

//What it should be

int dispenserType::getNoOfItems() const
{
return numberOfItems;
}; // end function getCost
int dispenserType::getCost() const
{
   return cost;
}

// it think u get it now. Still have any issue let me know.