Nov 4, 2012 at 4:11am UTC
#include<conio.h>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class employee {
private:
int dugaar;
char *name;
char *atushaal;
int tsag;
float basic;
float shagnal;
float tsalin;
public :
void showdata();
void nemelt(); //Zahiral bol shagnal mongo nemeh func
void getdata();
//Baiguulagch func
employee(void);
int setTsag(int a){
if(a>0 && a<24)
{
tsag=a+tsag;
}
}
int getTsag()
{
return tsag;
}
};
employee::employee()
{
name=new char[20];
strcpy(name,"");
dugaar=0;
basic=0;
tsag=0;
shagnal=100000;
}
void employee::getdata()
{
char n[20];
char t[20];
cout<<"\nAjilchnii dugaar :";cin>>dugaar;
cout<<"\nAjilchnii Ner :";cin>>n;
name=new char[strlen(n)+1];strcpy(name,n);
cout<<"\nAlban tushaal :";cin>>t;
atushaal=new char[strlen(t)+1];strcpy(atushaal,t);
cout<<"\nAjilsn Tsag :";cin>>tsag;
cout<<endl;
}
void heading()
{
cout<<endl;
for(int k=0;k<49;k++)
cout<<"-";
cout<<endl;
cout<<setw(8)<<"Dugaar";
cout<<setw(20)<<"Ajilchnii Ner";
cout<<setw(15)<<"Alban tushaal";
cout<<setw(5)<<"Tsag";
cout<<setw(8)<<"Tsalin";
}
void employee::showdata()
{
cout<<endl;
tsalin=basic*tsag;
char t[20];
strcpy(t,"zahiral");
cout<<setw(8)<<dugaar;
cout<<setw(20)<<name;
cout<<setw(15)<<atushaal;
if(strcmp(atushaal,t)==0)
{
nemelt();
}
cout<<setw(5)<<tsag;
cout.width(8);
cout<<tsalin;
cout<<endl;
}
int main()
{
int i,max;
cout<<"\nAjilchnii too oruul :";cin>>max;
employee emp[max];
for(i=0;i<max;i++)
emp[i].getdata();
heading();
for(i=0;i<max;i++)
emp[i].showdata();
int qq,aa,bb;
cout<<"\nAjilchnii tsagiig nemeh bol =1 ugui bol =2 :";cin>>aa;
switch(aa)
{
case 1:
cout<<"\nNemeh ajilchnii dugaar ";cin>>qq;
for(i=0;i<max;i++)
qq=qq-1;
cout<<"\nNemeh tsagaa oruul :";cin>>bb;
emp[qq].setTsag(bb);
case 2:
break;
}
for(i=0;i<max;i++)
emp[i].getdata();
heading();
for(i=0;i<max;i++)
emp[i].showdata();
getch();
}
Nov 4, 2012 at 5:24am UTC
Edit your above post to make use of the code tags (the <> in the format) otherwise your code is way to hard to read. And almost no one is going to take the time to decipher it.
Nov 4, 2012 at 5:24am UTC
Just adding code blocks so it is more readable! Might also help if you tell what is happening. Provide something more than just code.
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
#include<conio.h>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class employee {
private :
int dugaar;
char *name;
char *atushaal;
int tsag;
float basic;
float shagnal;
float tsalin;
public :
void showdata();
void nemelt(); //Zahiral bol shagnal mongo nemeh func
void getdata();
//Baiguulagch func
employee(void );
int setTsag(int a){
if (a>0 && a<24)
{
tsag=a+tsag;
}
}
int getTsag()
{
return tsag;
}
};
employee::employee()
{
name=new char [20];
strcpy(name,"" );
dugaar=0;
basic=0;
tsag=0;
shagnal=100000;
}
void employee::getdata()
{
char n[20];
char t[20];
cout<<"\nAjilchnii dugaar :" ;cin>>dugaar;
cout<<"\nAjilchnii Ner :" ;cin>>n;
name=new char [strlen(n)+1];strcpy(name,n);
cout<<"\nAlban tushaal :" ;cin>>t;
atushaal=new char [strlen(t)+1];strcpy(atushaal,t);
cout<<"\nAjilsn Tsag :" ;cin>>tsag;
cout<<endl;
}
void heading()
{
cout<<endl;
for (int k=0;k<49;k++)
cout<<"-" ;
cout<<endl;
cout<<setw(8)<<"Dugaar" ;
cout<<setw(20)<<"Ajilchnii Ner" ;
cout<<setw(15)<<"Alban tushaal" ;
cout<<setw(5)<<"Tsag" ;
cout<<setw(8)<<"Tsalin" ;
}
void employee::showdata()
{
cout<<endl;
tsalin=basic*tsag;
char t[20];
strcpy(t,"zahiral" );
cout<<setw(8)<<dugaar;
cout<<setw(20)<<name;
cout<<setw(15)<<atushaal;
if (strcmp(atushaal,t)==0)
{
nemelt();
}
cout<<setw(5)<<tsag;
cout.width(8);
cout<<tsalin;
cout<<endl;
}
int main()
{
int i,max;
cout<<"\nAjilchnii too oruul :" ;cin>>max;
employee emp[max];
for (i=0;i<max;i++)
emp[i].getdata();
heading();
for (i=0;i<max;i++)
emp[i].showdata();
int qq,aa,bb;
cout<<"\nAjilchnii tsagiig nemeh bol =1 ugui bol =2 :" ;cin>>aa;
switch (aa)
{
case 1:
cout<<"\nNemeh ajilchnii dugaar " ;cin>>qq;
for (i=0;i<max;i++)
qq=qq-1;
cout<<"\nNemeh tsagaa oruul :" ;cin>>bb;
emp[qq].setTsag(bb);
case 2:
break ;
}
for (i=0;i<max;i++)
emp[i].getdata();
heading();
for (i=0;i<max;i++)
emp[i].showdata();
getch();
}
Last edited on Nov 4, 2012 at 5:28am UTC
Nov 4, 2012 at 6:09am UTC
//this is new
#include<conio.h>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class employee {
private:
int number;
char *name;
char *career;
int hour;
float basicpay;
float allowance;
float grosspay;
public :
void showdata();
void bonus(); //if career is boss,add extra money
void getdata();
//Baiguulagch func
employee(void);
int setHour(int a){
if(a>0 && a<24)
{
hour=a+hour;
}
}
int getHour()
{
return hour;
}
};
employee::employee()
{
name=new char[20];
strcpy(name,"");
number=0;
basicpay=0;
hour=0;
allowance=100000;
}
void employee::getdata()
{
char n[20];
char t[20];
cout<<"\nEnter employee number :";cin>>number;
cout<<"\nEmployee name :";cin>>n;
name=new char[strlen(n)+1];strcpy(name,n);
cout<<"\nEmployee career :";cin>>t;
career=new char[strlen(t)+1];strcpy(career,t);
cout<<"\nWork hour :";cin>>hour;
cout<<endl;
}
void heading()
{
cout<<endl;
for(int k=0;k<49;k++)
cout<<"-";
cout<<endl;
cout<<setw(8)<<"Number";
cout<<setw(20)<<"Employee Name";
cout<<setw(15)<<"Employee career";
cout<<setw(5)<<"Hour";
cout<<setw(8)<<"Grosspay";
}
void employee::showdata()
{
cout<<endl;
grosspay=basicpay*hour;
char t[20];
strcpy(t,"boss");
cout<<setw(8)<<number;
cout<<setw(20)<<name;
cout<<setw(15)<<career;
if(strcmp(career,t)==0)
{
bonus();
}
cout<<setw(5)<<hour;
cout.width(8);
cout<<grosspay;
cout<<endl;
}
int main()
{
int i,max;
cout<<"\nEnter worker number :";cin>>max;
employee emp[max];
for(i=0;i<max;i++)
emp[i].getdata();
heading();
for(i=0;i<max;i++)
emp[i].showdata();
int qq,aa,bb;
cout<<"\nif Work hour add =1 ugui else =2 :";cin>>aa;
switch(aa)
{
case 1:
cout<<"\nEnter worker number ";cin>>qq;
for(i=0;i<max;i++)
qq=qq-1;
cout<<"\nEnter extra work hour :";cin>>bb;
emp[qq].setTsag(bb);
case 2:
break;
}
for(i=0;i<max;i++)
emp[i].getdata();
heading();
for(i=0;i<max;i++)
emp[i].showdata();
getch();
}
Nov 4, 2012 at 6:59pm UTC
You still did not place it in code brackets and did not tell what the problem is that you are having.
Last edited on Nov 4, 2012 at 6:59pm UTC