Guys, can you help me with my project
I can't see what's wrong with my program.
The errors are:
Line 138: Expected primary-expression before "int"
Line 138: Expected ';' before "int"
Line 158: Expected '}' at end of input

#include<iostream>
using namespace std;


int telephone_bill()
{   int choice, min, tbill, coun, con;

        cout<<"Welcome to Telephone Bill Service!";
        cout<<"\nChoose if\n <1>Local Call <2>International Call";
        cout<<"\nYour choice:";
        cin>>choice;
if (choice==1)
   {system("cls");
    cout<<"\nThe rate for Local Call is 3.00PhP.";
    cout<<"\nHow many minute(s):";
    cin>>min;
    tbill=min*3.00;
    cout<<"\nYour total Telephone Bill is "<< tbill<<".00";
    }
else if (choice==2)
    {system("cls");cout<<"\nChoose a country:";
     cout<<"\n1. America\t\t2.Europe\n3.Australia\t\t4.Singapore";
     cout<<"\nCountry:";
     cin>>coun;
     if (coun==1)
     {system("cls");cout<<"\nThe rate for call to America is 10.00.";
      cout<<"\nHow many minute(s):";
      cin>>min;
      tbill=min*10.00;
      cout<<"\nYour total Telephone Bill is "<<tbill<<".00";
     }
      else if (coun==2)
     {system("cls");cout<<"\nThe rate for call to Europe is 12.00.";
      cout<<"\nHow many minute(s):";
      cin>>min;
      tbill=min*12.00;
      cout<<"\nYour total Telephone Bill is "<<tbill<<".00";
     }
     else if (coun==3)
     {system("cls");cout<<"\nThe rate for call to Australia is 8.00.";
      cout<<"\nHow many minute(s):";
      cin>>min;
      tbill=min*8.00;
      cout<<"\nYour total Telephone Bill is "<<tbill<<".00";
     }
     else if (coun==4)
     {system("cls");cout<<"\nThe rate for call to Singapore is 6.00.";
      cout<<"\nHow many minute(s):";
      cin>>min;
      tbill=min*6.00;
      cout<<"\nYour total Telephone Bill is "<<tbill<<".00";
     }
     else
     {system("cls");cout<<"\nError!";
     }
     }
else
{cout<<"\nError!";
 cout<<"\nProgram Terminated.";
     }
     }


int electric_bill()
{ int kw, ebill,ebill1,disc,balance,k;
  cout<<"Welcome to Electric Billing Service!";
  cout<<"\n\nThe rate of electric per kilowatt hour is 5.00.";
  cout<<"\n\nEnter your Electric Consumption:";
  cin>>kw;
  ebill1=kw*5.00;
  if (kw>=500)
     {cout<<"\n\nYou have 10% Discount on your total bill!";
      disc=(ebill1*.10);
      ebill=(ebill1-disc);
      cout<<"\nYou have discount of "<<disc<<".00";
      cout<<"\n\nYour Electric Bill with Discount is "<<ebill1<<".00";
      }
  else
     {cout<<"\nSorry You don't have discount.";
     disc=0;
      cout<<"\nYour Total Electric is "<<ebill1<<".00";
     }
    cout<<"\n\nDo you have any balance on your last bill?";
    cout<<"\n<1>Yes\t<2>No\n";
    cout<<"Your Choice:";
    cin>>k;
    if (k==1)
    {cout<<"\n\nYour ramaining balance:";
    cin>>balance;
    ebill=(ebill1+balance)-disc;
    cout<<"\n\nYour total Electric bill is "<<ebill<<".00";
    }
    else if (k==2)
    {ebill=ebill1-disc;
     cout<<"Your Total Bill is "<<ebill<<".00";
     }
     else
     {cout<<"\n\nError!";
     }}


     int water_bill()
{   int wat, wbill, wbill1, discount, bal, q;
    cout<<"Welcome to Water Billing Services!";
    cout<<"\n\nThe rate for water is 3.00.";
    cout<<"\n\nEnter your Water Consumption:";
    cin>>wat;
    wbill1=wat*3.00;
    if (wat>=500)
    {cout<<"\n\nYou have a 10% Discount on your bill!";
    discount=wbill1*.010;
    cout<<"\n\nYour bill is "<<wbill1<<".00";
    cout<<"\nYou've discounted by "<<discount<<".00";
    }
    else
    {cout<<"\n\nSorry, You don't have discount.";
    discount=0;
     cout<<"\n\nYour bill is "<<wbill1<<".00";
}
    cout<<"\n\nDo you have any balance on your last bill?";
    cout<<"\n<1>Yes\t<2>No\n";
    cout<<"Your Choice:";
    cin>>q;
    if (q==1)
    {cout<<"\n\nYour ramaining balance:";
    cin>>bal;
    wbill=(wbill1+bal)-discount;
    cout<<"\n\nYour total Water bill is "<<wbill<<".00";
    }
    else if (q==2)
    {wbill=wbill1-discount;
     cout<<"Your Total Bill is "<<wbill<<".00";
     }
     else
     {cout<<"\n\nError!";
     }

int main()
{ int a;
      cout<<"Welcome to Bayad Center!";
      cout<<"\nPlease choose a service:";
      cout<<"\n<1>Telephone Billing Service\n<2>Electric Billing Service\n<3>Water Billing Service\n<4>Exit";
      cout<<"\nYour Choice:";
      cin>>a;
      switch (a)
      {      case 1: system("cls");system("Color 3D");telephone_bill();
                     break;
             case 2: system("cls");system("Color 3C");electric_bill();
                     break;
             case 3: system("cls");system("Color 4E");water_bill();
                     break;
             case 4: system("cls");system("Color 9F");cout<<"\nProgram Terminated.";
                     break;
             default: cout<<"\nError!";
      }
      system("Pause");
return 0;
}

Edited 3 Years Ago by illyaizevielvon.einzbern

Your immediate problem is you're missing the closing brace for water_bill. This highlights the importance of formatting. If you keep the first statement after the opening brace on a separate line and use proper indentation, these little errors are much easier to find.

If your IDE/Compiler doesn't have a formatting function you should find one that does. On windows both code::blocks and Visual Studio are free and have formatting functions.

The next thing I noticed is that all your functions, outside of main, are supposed to return an int but they don't.

Edited 3 Years Ago by tinstaafl

Format your code properly so that you can find or prevent errors like a missing curly brace. There should another curly brace after line 136.

you defined water_bill() , telephone_bill() and electric_bill() as int functions so they should be returning an integer!

However, i dont see what you would be returning so i think your functions should be void instead of int.

void water_bill(){
    ...
}

Likewise for electric and telephone bill functions.

It may also help to read up on indent style (also called brace style) to help clarify the issue at hand. There are several ways to format C++ code, all of which have their advantages and disadvantages; the most important things are that you use a style that is widely known, and that you are consistent in applying your chosen style throughout a given program.

Edited 3 Years Ago by Schol-R-LEA

Sir I already solve the errors in my program
but my problem is my program has a short-circuit
can you help me to output the result 'coz it makes me dizzy when I thinking about how to solve the short-circuit.
Thanks to your help and God bless :D

Could you please explain "short-circuit"? Your confusion is also attributed by your naming convention. A function DOES something, so it is better to use a verb.
Say, instead of void water_bill() {...} better use void CalculateWaterBill() {...}. It is clearer this way and won't cause headache.

This question has already been answered. Start a new discussion instead.