Proceedural program

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();
}


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 main()
{
if (grade=='A'||grade=='a')

gradea();

else (grade=='B'||grade=='b'_

gradeb();


else (grade=='C'||grade=='c')

gradec();

}



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 while1()
{

while (term !='n'&& term !='N');//End of the WHILE loop
}


//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;
}




void close()
{
//Closing message
cout<<"\n\n Press ' and enter to continue";
cin>>enter;
clrscr();
cout<<"\n\nThanks for using my program";
}

I keep getting a message saying , the do statement must have a while , I have had this error before and it was because there was to many brackets. However in this program I cannot see any extra ones. Thanks
C++ Borlands (Old I know)
At a first glance:

else (grade=='B'||grade=='b'_
you places function definition inside the while:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void input()
{
  do{

     void main{   //not allowed, and btw -->> should be: int main
     }

     //more functions -  not allowed

     void while1()  //not allowed
     {
       while(somthing);  
     }

  //while never ended...

} 


you can not define function inside functions!
The functions inside the while are the right syntax(i think), but they are not supposed to be place inside the loop...
Only the close function is in the right place..

You should really rewrite your code..
Last edited on
hmm after looking a bit better i think this i what you ment:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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( something ); //   <<-------------
}
Thanks for the help, and I will work on my programming thanks for the help!
Update* It is still saying the do must have a while ? Any help would be appreciated
The do statement needs a while condition to know which criteria needs to be satisfied in order for the loop to reiterate.

http://msdn.microsoft.com/en-us/library/b0kk5few.aspx
Thanks, I already knew it needed it to be satisfied and it's been put in but I think I have put it in the wrong location as I have been told to make the prorgram using proceedures which makes everything just a bit complicated especially when doing loops
It needs to directly follow the closing brace of the 'do' scope.

1
2
3
4
do
{
   // Do stuff
} while ( condition )  
Thanks very much ! It has cleared up that issue and now I've just got a declaration syntax issue, no worries I'll deal with it myself, thanks :D
Topic archived. No new replies allowed.