int ID,hours,pay1,staff,OT,OTH,GP,NP,i,total;
char enter,grade,depname[10],b,B,a,term;
void open()
{
//Welcoming message
cout<<" ------- -- -- ----- ------- ----- --- ---- -- --------"<<endl;
cout<<" Welcome to my Wages program, Press ' and enter to continue"<<endl;
cout<<" ------- -- -- ----- ------- ----- --- ----- -- --------"<<endl;
cin>>enter;
GP=0;
}
void input()
{
do
{
//Asking for the user to enter the department name
cout<<"Please enter your Department name\n\n"<<endl;
cin>>depname;
//Asking to enter the no. of staff
cout<<"Please enter the number of staff in your department\n\n"<<endl;
cin>>staff;
//Asking for employee ID
cout<<" Please enter your employee ID\n\n"<<endl;
cin>>ID;
//Asking for grade
cout<<"Please enter your Grade\n\n"<<endl;
cin>>grade;
//Asked to carry on to the next screen
cout<<"Please continue on to the next screen, press ' and enter to do so."<<endl;
cin>>enter;
//clearing the screen
clrscr();
//Enter the amount of hours worked
cout<<"Please enter the amount of hours that you have worked\n\n"<<endl;
cin>>hours;
//Clearing the screen
cout<<"Press Enter and ' to continue"<<endl;
cin>>enter;
clrscr();
}while (term !='n'&& term !='N');
}
void gradea()
{
if ( grade=='A' || grade =='a')
if (hours<=40)
{
//Calculating the normal pay
pay1=hours*10;
OTH=hours-40;
//Outputing the results
cout<<"\n\nID :"<<ID<<endl;
cout<<"\n\nGrade :"<<grade<<endl;
cout<<"\n\nYou have been paid "<<"£"<<pay1<<" For "<<hours<<" hours work"<<endl;
cout<<"\n\nYou have been paid £0 for "<<OTH<<"hours work"<<endl;
cout<<"\n\nGross Pay £"<<pay1<<endl;
}
//Else statement
else
//If statement
if (hours>40)
{
//calculating the over time pay
OTH=hours-40;
OT=OTH*15;
pay1=hours-OTH;
NP=pay1*10;
GP=NP+OT;
//Oututing the results
cout<<"\n\nID : "<<ID<<endl;
cout<<"\n\nGrade : "<<grade<<endl;
cout<<"\n\nDeparment name : "<<depname<<endl;
cout<<"\n\nYou have been paid £ "<<NP<<" For "<<hours<<" hours work"<<endl;
cout<<"\n\nYou have been paid £ "<<OT<<" For"<<OTH<<" hours work"<<endl;
cout<<"\n\nGross Pay : "<<"£"<<GP<<endl;
}
}
void gradeb()
{
//Double if statement
if ( grade=='B' || grade =='b')
if (hours<=40)
{
//Calculating the normal pay
pay1=hours*8;
OTH=hours-40;
//Output the results
cout<<"\n\nID :"<<ID<<endl;
cout<<"\n\nGrade :"<<grade<<endl;
cout<<"\n\nYou have been paid "<<"£"<<pay1<<" For "<<hours<<" hours work"<<endl;
cout<<"\n\nYou have been paid £0 for "<<OTH<<"hours work"<<endl;
cout<<"\n\nGross Pay £"<<pay1<<endl;
}
//Else statement
else
//If statement
if (hours>40)
{
//calculating the over time pay
OTH=hours-40;
OT=OTH*12;
pay1=hours-OTH;
NP=pay1*8;
GP=NP+OT;
//Output the results
cout<<"\n\nID : "<<ID<<endl;
cout<<"\n\nGrade : "<<grade<<endl;
cout<<"\n\nDeparment name : "<<depname<<endl;
cout<<"\n\nYou have been paid £ "<<NP<<" For "<<hours<<" hours work"<<endl;
cout<<"\n\nYou have been paid £ "<<OT<<" For"<<OTH<<" hours work"<<endl;
cout<<"\n\nGross Pay : "<<"£"<<GP<<endl;
}
}
void gradec()
{
if ( grade=='c' || grade =='C')
if (hours<=40)
{
//Calculating the normal pay
pay1=hours*6;
OTH=hours-40;
//Output the results
cout<<"\n\nID :"<<ID<<endl;
cout<<"\n\nGrade :"<<grade<<endl;
cout<<"\n\nYou have been paid "<<"£"<<pay1<<" For "<<hours<<" hours work"<<endl;
cout<<"\n\nYou have been paid £0 for "<<OTH<<"hours work"<<endl;
cout<<"\n\nGross Pay £"<<pay1<<endl;
}
//Else statement
else
//If statement
if (hours>40)
{
//calculating the over time pay
OTH=hours-40;
OT=OTH*9;
pay1=hours-OTH;
NP=pay1*6;
GP=NP+OT;
//Output the results
cout<<"\n\nID : "<<ID<<endl;
cout<<"\n\nGrade : "<<grade<<endl;
cout<<"\n\nDeparment name : "<<depname<<endl;
cout<<"\n\nYou have been paid £ "<<NP<<" For "<<hours<<" hours work"<<endl;
cout<<"\n\nYou have been paid £ "<<OT<<" For"<<OTH<<" hours work"<<endl;
cout<<"\n\nGross Pay : "<<"£"<<GP<<endl;
}
void close();
{
//Closing message
cout<<"\n\n Press ' and enter to continue";
cin>>enter;
clrscr();
cout<<"\n\nThanks for using my program";
}
void main();
{
void input();
if(grade=='A'||grade=='a')
gradea();
else if(grade=='B'||grade=='b')
gradeb();
else(grade=='C'||grade=='c')
gradec();
close();
}
void wage();
{
//Asking if you want to work out another wage
cout<<"To work out another wage enter a Y otherwise enter N"<<endl;
cin>>term;
clrscr();
total = GP + GP ;
}
void slip();
{
//Output the results
cout<<"\n\n----PAY SLIP----"<<endl;
cout<<"\n\nDate : "<<"15/01/10"<<endl;
cout<<"\n\nDeparment name : "<<depname<<endl;
cout<<"\n\nNumber of staff : "<<staff<<endl;
cout<<"\n\nTotal weekly gross pay : £ "<<total<<endl;
}
}
I am getting the following error and cannot get rid of it I have spent hours looking at it but cannot find a solution wondering if anyone can help?
Linking F:\PAY.EXE:
Linker Warning: No module definition file specified: using defaults
Linker Error: Undefined symbol _main in module WINMAIN
Look at your project settings. Your Project should be linked to a console application. The error message says that the linker expects a WinMain function as main entry point for a WIN32 application instead of a "normal" main function.
You don't have a main function. Where is your program supposed to begin?
This: void main();
declares the existence of a function called main that takes no parameters and returns none. It is not an actual main function.
I suspect you meant this:
1 2 3 4
void main()
{
...
...
which is still wrong, as in C++ main must return an int, so try this instead:
1 2 3 4
int main()
{
...
...
As it is, you're clearly using a C++ compiler from before 1998. What your compiler considers to be C++ has not been C++ for a very long time. Consider getting a modern C++ compiler for free to replace it.
I know it's the program we use at college so I haven't got control over what we make the programs in. Also I changed the void main to an int main and I am still receiving the same error
Your college chooses to teach outdated (i.e. wrong) C++ when they could be teaching modern (correct) C++ for free. Harsh, but sadly not uncommon.
Did you also remove the semi-colon, like I said, and also wrap your code inside the main function, like I said?
Here is a simple example.
What you did:
1 2 3
void main();
// Code here
What I suggested
1 2 3 4 5 6
int main()
{
// Code here
}
You will note that some of your other function suffer the same problem:
Bad: void close();
Good: void close()
Bad: void input();
Good: void input()
Likewise wage and slip. You need to go back to the basics of how to write a function and make sure that you're putting the semi-colons in the right place, and understand the difference between a function prototype and the actual function.
Edit:
As an aside, you keep saying "procedure"; the far more common term in C++ is function (I see "method" as well, but that seems to be more common in C and Obj-C circles).
Oh okay , thanks for the help tremendously I will begin bringing in my laptop to code from now on , I always thought we were using an outdated program but not this bad , thanks for the reality check.