GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-Dec-2010, 01:26
nomee.malik nomee.malik is offline
New Member
 
Join Date: Dec 2010
Posts: 1
nomee.malik is on a distinguished road
Unhappy

Error C2059: syntax error : '} '


i know that the code is really Conjusted. but in my defence in a "Total n00b" and made this in one day.

i keep getting this error [ error C2059: syntax error : ' } ']

any help will be appriciated
heres the code.


CPP / C++ / C Code:
#include<iostream.h>
#include<string.h>
void admin(); /// function for admin to impliment changes on the stock
void error(int error_num); /// function to display error messages
void item_list(int item_number); /// function to display item catagories
int item_price(int item_code); /// function to store item price
int grocerie_list(int item_code); /// function to sture grocrie products
int fruits_vegs_list(int item_code);/// function to store fruits and vegetables
int gros_price(int item_code); /// function for price of grocery produnts
int frut_veg_price(int); /// function for price of fruits & vegetables


/////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////MAIN FUNCTION////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////

void main()
{
 int mainop, op2, unit, itemcode, op3,allitems;
 float t_sum=0;
 char ch1,ch2,ch3,fp,mainch;
 cout<<"\t\t******************************************\n";
 cout<<"\t\t*                                        *\n";
 cout<<"\t\t*  .::Welcome To Supermarket Program::.  *\n";
 cout<<"\t\t* *\n";
 cout<<"\t\t******************************************\n";
 do{
  cout<<"\n\t\t\t Please Enter Your Choice.";
  cout<<"\n\t\t\t 1. View Items.";
  cout<<"\n\t\t\t 2. Customer.";
  cout<<"\n\t\t\t Your Choice: ";
  cin>>mainop;
  if(mainop>0 && mainop<=2)
  {
   switch(mainop)
   {
   
    default:
     error(1);
     break;

    case 1:
	item_list(mainop);
	break;
        
    case 2:
     do{
      cout<<"\n\t\t\t .Buy Items."<<endl;
      cout<<"\n\t\t\t Enter your Choice('y' or 'n'): ";
      cin>>ch2;
 while(ch2=='y' || ch2=='Y')
 {
 if(op2>0 && op2<=2)
      {
       switch(op2)
       {
		case 1:
			item_list(op2);
			break;
		case 2:
		do{
         cout<<"\n\t Enter Choice :";
         cout<<"\n\t 1. Groceries.";
         cout<<"\n\t 2. Fruits & Vegetables.";
         cout<<"\n\t Your Choice: ";
         cin>>op3;
         if(op3>0 && op3<=2)
         {
			switch(op3)
			{
			case 1:
           
			do{
            cout<<"\n\nWrite Item Code:";
            cin>>itemcode;
            if(itemcode>0 && itemcode<allitems)
            {
             cout<<"\nItem number-"<<grocerie_list(itemcode);
             cout<<" has been found in our database.";
             cout<<"\nThe Price is:"<<gros_price(itemcode);
             cout<<"\n\nHow Many units do you want?";
             cin>>unit;
     
             if(unit>0 && unit<100)
              {
               t_sum=t_sum+(grocerie_list(itemcode)*unit);
               cout<<"\nTotal sum has been added to your cart.";
               cout<<"\nYour total right now="<<t_sum<<"  R.s";
              }
 
            }
            else
            
            cout<<"\nWrong Code"<<endl;
			cout<<"Buy More Products ?";
			cin>>ch1;
            
            }while ( ch1 == 'Y' || ch1 == 'y' ) ;
			cout<<"\n\nTotal Sum: "<<t_sum<<" R.s";
			break;
          
          case 2:
           do{
            cout<<"\n\nWrite Item Code:";
            cin>>itemcode;
            if(itemcode>0 && itemcode<allitems)
            {
             cout<<"\nItem number-"<<fruits_vegs_list(itemcode);
             cout<<" has been found in our database.";
             cout<<"\nThe Price is:"<<frut_veg_price(itemcode);
             cout<<"\n\nHow Many units do you want?";
             cin>>unit;
     
             if(unit>0 && unit<100)
             {
              t_sum=t_sum+(item_price(itemcode)*unit);
              cout<<"\nTotal sum has been added to your cart.";
              cout<<"\nYour total right now="<<t_sum<<"  R.s";
             }
            
            }
            
            else
            cout<<"\nWrong Item Code";

			}while ( ch1 == 'Y' || ch1 == 'y' ) ;

           cout<<"\n\nTotal Sum: "<<t_sum<<" R.s";
           break;

          default:
           error(2);
           break;
          }
         }// if loop end

        cout << "\n\n Do You Want To Buy More Products : " ;
        cin >> fp ;

        }while( fp == 'y' );
       
       }
      }
      cout<<"\nDo You Want to Try Again: ";
     cin>>ch3;
     }while( ch3== 'y' );
     }// Switch end
        }//if end
      cout<<"\n\n Do You Want To Try Again? :";
           cin>>mainch;
     }
}
     while( mainch == 'y');
     }

//////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////ADMIN FUNCTION//////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

void admin()
{
    char op,ch1,password[20];
    cout<<"\nPlease Enter Password: ";
    cin>>password[20];
    if(password=="admin123")
    {
        cout<<"\n\t\t1. Display Stock.";
        cout<<"\n\t\t2. Add Stock.";
        cout<<"\n\t\t3. Delete Stock.";
        
        do{
        switch(op)
        {
            case 1:
                item_list(op);
                break;
            
            default:
                error(3);
                break;
        }
        }while(ch1 == 'y');
        
    }
    else
        cout<<"Wrong Option";
}


//////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////ERROR FUNCTION/////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

void error (int error_num) 
{
    switch (error_num) 
    {
        default :
        cout << " \n\n\t --> ErrorMsg-(Default) : There's Some Thing Seems To Be Wrong . " ;
        break ;
        case 1 :
        cout << " \n\n --> ErrorMsg-(1) : This Option Is Not On List Please Chose One Listed Up " ;
        break ;
        case 2 :
        cout << " \n\n --> ErrorMsg-(2) : Option Not Listed " ;
        break ;
        case 3 :
        cout << " \n\n --> ErrorMsg-(3) : Option Not Listed . " ;
        break ;
        
    }
}


//////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////Item List Function/////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

void Item_list()
{
    int op;
    cout<<"\n\t\t\t Choose your Option";
    cout<<"\n\t\t\t 1. Groceries.";
    cout<<"\n\t\t\t 2. Fruits And Vegetables.";
    cout<<"\n\t\t\t Your Option: ";
    cin>>op;
    if(op == 1)
        grocerie_list(op);
    else if(op == 2)
        fruits_vegs_list(op);
    else 
        error(3);

}



//////////////////////////////////////////////////////////////////////////////////////
/********************Function for displaying item price******************************/
//  function contains two more functions which display the prices of fruits //
//  and vegetables //////
//////////////////////////////////////////////////////////////////////////////////////

void item_price()
{
cout<<"\n\t\t 1. Grocery Price List.";
int gros_price();
cout<<"\n\t\t 2. Fruits & Vegetable Price.";
int frut_veg_price();
}


int grocerie_list(int item_code)
{
switch(item_code)
{
case 1:
cout<<"Bread";
break;
case 2:
cout<<"Butter";
break;
case 3:
cout<<"Milk";
break;
case 4:
cout<<"Eggs";
break;
case 5:
cout<<"Cookies";
break;
case 6:
cout<<"Chips";
break;
case 7:
cout<<"Cigarette";
break;
case 8:
cout<<"Pepsi (Large)";
break;
case 9:
cout<<"Pepsi (small)";
break;
case 10:
cout<<"Cheese";
break;

}
return item_code;
}
int fruits_vegs_list(int item_code)
{
switch(item_code)
{
case 1:
cout<<"Apples (per Kg)";
break;
case 2:
cout<<"Oranges (per Kg)";
break;
case 3:
cout<<"Bananas (per 12 pieces)";
break;
case 4:
cout<<"Grapes (per Kg)";
break;
case 5:
cout<<"Peach (per Kg)";
break;
case 6:
cout<<"carrots (per Kg)";
break;
case 7:
cout<<"Tomatos (per Kg)";
break;
case 8:
cout<<"Ginger (per Kg)";
break;
case 9:
cout<<"Onion (per Kg)";
break;
case 10:
cout<<"Potato (per Kg)";
break;
}
}

int gros_price(int item_code)
{
float item_charge;
switch(item_code)
{
case 1: //item 1
item_charge=45;
break;
case 2: //item 2
item_charge=50;
break;
case 3: //item 3
item_charge=65;
break;
case 4: //item 4
item_charge=85;
break;
case 5: //item 5
item_charge=20;
break;
case 6: //item 6
item_charge=15;
break;
case 7: //item 7
item_charge=43;
break;
case 8: //item 8
item_charge=70;
break;
case 9: //item 9
item_charge=35;
break;
case 10://item 10
item_charge=170;
break;

}
}
int fruit_veg_price(int item_code)
{
float item_charge;
switch(item_code)
{
case 1: //item 
item_charge=85;
break;
case 2: //item 2
item_charge=75;
break;
case 3: //item 3
item_charge=35;
break;
case 4: //item 4
item_charge=180;
break;
case 5: //item 5
item_charge=75;
break;
case 6: //item 6
item_charge=30;
break;
case 7: //item 7
item_charge=63;
break;
case 8: //item 8
item_charge=52;
break;
case 9: //item 9
item_charge=136;
break;
case 10://item 10
item_charge=142;
break;
}

}
Last edited by LuciWiz : 16-Dec-2010 at 02:33. Reason: Please insert your C++ code between [cpp] & [/cpp] tags
  #2  
Old 21-Dec-2010, 10:32
Howard_L Howard_L is offline
Senior Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 1,007
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Error C2059: syntax error : '} '


Your program contains unclosed braces
and runaway case statements
and a missing function
and function declarations that don't match the definitions
and functions that don't return a value (like "int main(void)" for one)

If you were to build and test your program a little at a time
and use good indenting style
these problems would show up as they are written
and NOT all at once when you THINK you have the program finished.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help : error C2059: syntax error : 'constant' mattchew008 C++ Forum 13 09-Dec-2007 19:21
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 15:41
Syntax error Saint C Programming Language 4 28-Aug-2004 03:20
Hmm what seems to be the problem here? error C2061: syntax error pablowablo C++ Forum 5 12-Jun-2004 22:11
Error C2143: syntax error : missing ';' before 'type' small_ticket C Programming Language 6 15-May-2004 11:59

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 12:51.


vBulletin, Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.