5 functions

# include <iostream.h>
main()
{
int hours=0,day=0,rate=0,gross=0;
int num=0;
{
cout<<"no. of employee";cin>>num;
int x;
for (x=1;x<=num;x++)
int sss=300,pagibig=100;
double tax=0,td=0,net=0;
cout<<"Hours Days Worked";cin>>day;
cout<<"Hours Late";cin>>hours;
cout<<"Enter Position:\n M- Manager \tS-Supervisor \tT-Staff";
cin>>position;
if((position='m')||(position=='M'))
{
rate=400;
}
else if ((position=='s')||(position=='S'))
{
rate=350;
}
else
{
rate=300;
}
gross=((rate*day)-((rate/8)*hours));
cout<<"Gross"<<gross<<endl;
tax=gross*.10;
td=tax+sss+pagibig;
net=gross-td;
cout<<"tax:"<<tax<<endl<<"SSS:"<<sss<<endl<<"Pag-ibig:"<<pagibig<<endl<<"Net:"<<net<<endl;
return 0;
}
}

This is my program, what i need is to processed it under 5 function using the call parameter under typename (parameter1,parameter2)and to repeat this form this form as many times the user input the no of employee...I think i lack enough function and I cannot rpeat the process using for loop,any help sir...thanks in advance!
You need to move all the code that does something specific out of main() and into another function.

Start here. It is an excellent resource.
http://www.cplusplus.com/doc/tutorial/functions.html

Good luck!
Last edited on
I tried to read but I gues? Im still out of logic...any hint or ideas of anything i could do to rewrite my codes,thanks...
So i need to be specific out of the main and into another function, can someone site a good example in my program...
1
2
3
4
5
6
7
8
9
10
11
12
13
14

int getRate(char position) {
 if (position == 's')
   return 400;

 return 0;
}

int main() {
 // do some stuff
 rate = getRate(position);
 return 0;
}

Last edited on
thanks Im starting to get on with this...but still a bit confused and makes me dizzy!....
Topic archived. No new replies allowed.