#include <iostream>
using namespace std;
//Function declare
void displayMenu(void);
void getSelection (int &userChoice);
void processChoice (int userChoice);

float monitorCoke( float, float );
float monitorpep ( float ,float ); 
float monitorcana ( float ,float);
float monitorhire ( float,float ) ;
 // variable declare and const
 
float option, cocaout, pepsiout ,canaout,pepleft,canaleft,cokeleft,hireout;
const float coke = 1000;
const float pep = 1000;
const float cana = 1000;
const float hires = 1000;
float get_option;

//Main
int main (void)
{
    int userChoice =0;
    displayMenu();
    getSelection(userChoice);
    processChoice (userChoice);
    monitorCoke(  cokeleft, cocaout);
    monitorpep ( pepleft, pepsiout) ;
    monitorcana (  canaleft, canaout);
     float monitorhire ( float hireleft,float hireout) ;
    return 0;
}
//end main

//start function
void displaymenu(void)
{
     cout << " Have a nice week. Each product will have 1000 pieces a week" <<endl;
     cout << " 1. Coca-Cola : 1000 pieces" << endl;
     cout << " 2. Pepsi : 1000 pieces" << endl;
     cout << " 3. Canada Dry" << endl;
     cout << " 4. Hires " << endl;
     }
void getSelection (int &userChoice)
{
     cout <<  "Please enter your choice:" << endl;
     cin>> userChoice;
     }
void processChoice (int userChoice)
{
if (option == 1.0)
{
          
           cout<< "How many Coca-cola  would you like: " << endl;
           cin>>  cocaout; 
           }
           else if (option == 2.0 ) 
           {

              
                      cout<< "How many Pepsi would you like: " << endl;
                      cin >> pepsiout;
                     
                }
                
           else if ( option ==3.0 )
           {
                   cout<< "How many Canada Dry would you like: " << endl;
                   cin >> canaout;
                 
             
                   }
           else if ( option == 4.0) 
           {
                         cout<< "How many Hires would you like: " << endl;
                         cin>> hireout;
                         }// end if



float monitorCoke( float cokeleft,float cocaout)
        {
            cocaout = 0;
           cokeleft = coke;
           while ( cocaout < cokeleft)
           {
           cokeleft = cokeleft - cocaout; 
           cout << " There are " << cokeleft << " Coca-cola left in the machine " << endl;
          
           }
           return cokeleft;
        }
           
           
 float monitorpep ( float pepleft,float pepsiout)                        
           {
           pepsiout = 0 
           pepleft = pep ;
           while (pepsiout < pepleft)    
           {
           pepleft = pepleft - pepsiout; 
           cout << " There are " << pepleft << "Pepsi left in the machine " << endl;
           }
           return pepleft;
           }//end function monitorpep
 float monitorcana ( float canaleft,float canaout)                        
 {
           canaout = 0 
           canaleft = canaleft - canaout ;
           while (canaout < canaleft)
           
           {
                    canaleft = canaleft - canaout; 
           cout << " There are " << canaleft << "Canada Dry left in the machine " << endl;
           
           }
           return canaleft;
           }// end monitorcana
  float monitorhire ( float hireleft,float hireout)                        
  {
           hireout = 0 
           hireleft = hire ;
           while (canaout < canaleft)
           
           {
                    hireleft = hireleft - hireout; 
           cout << " There are " << hireleft << "Hires left  in the machine " << endl;
           
           }
           return hireleft;
           }// end monitorhire

the error in the float monitor function that say the function definition is not allowed here before {

please help me and give me some advise about the way I coding too

float monitorhire ( float hireleft,float hireout) ; This is wrong declaration inside main()!

Advice: don't use so much global variables (none would be best)

WHICH { ? You have a bunch of them. In addition to what Sci@phy mentioned, you have a bracket problem here too:

void processChoice (int userChoice)
{
if (option == 1.0)
{
          
           cout<< "How many Coca-cola  would you like: " << endl;
           cin>>  cocaout; 
           }
           else if (option == 2.0 ) 
           {

              
                      cout<< "How many Pepsi would you like: " << endl;
                      cin >> pepsiout;
                     
                }
                
           else if ( option ==3.0 )
           {
                   cout<< "How many Canada Dry would you like: " << endl;
                   cin >> canaout;
                 
             
                   }
           else if ( option == 4.0) 
           {
                         cout<< "How many Hires would you like: " << endl;
                         cin>> hireout;
                         }// end if



float monitorCoke( float cokeleft,float cocaout)

That bracket in red is ending an if statement, so there's no bracket ending the function itself before the next function starts.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.