upsidedown

OOPS EXPT 2

Jan 27th, 2012
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. #include<iostream.h>
  2.  
  3. class empolyee
  4. {
  5.     char name[50];
  6.     int ID;
  7.     float basic, salary;
  8.  
  9. public:
  10.     void getdata()
  11.     {
  12.         cout<<"Enter ID"<<endl;
  13.         cin>>ID;
  14.         cout<<"Enter name"<<endl;
  15.         cin>>name;
  16.         cout<<"Enter basic";
  17.         cin>>basic;
  18.     }
  19.  
  20.     void calc(int bonus=0)
  21.     {
  22.         float hra = basic*0.15;
  23.         float da=basic*0.15;
  24.  
  25.         salary= basic+ hra+ da+ bonus;
  26.     }
  27.  
  28.     void display()
  29.     {
  30.         cout<<"\n"<<ID<<"\t"<<name<<"\t"<<basic<<"\t"<<salary;
  31.     }
  32.  
  33.  
  34. }a[50];
  35.  
  36.  
  37. int main()
  38. {
  39.     int n;
  40.     cout<<"\nenter no of employees";
  41.     cin>>n;
  42.  
  43.     //empolyee a[50];
  44.  
  45.     for(int i=0;i<n;i++)
  46.     {
  47.         a[i].getdata();
  48.         if(i<5)
  49.           a[i].calc(700);
  50.         else if(i>=n-5&&i>4)
  51.             a[i].calc(250);
  52.         else
  53.             a[i].calc();
  54.        
  55.     }
  56.  
  57.  
  58.     cout<<"\n the employee details are\n";
  59.     cout<<"\nID\tName\tBasic\tsalary";
  60.     for( i=0;i<n;i++)
  61.     {
  62.         a[i].display();
  63.     }
  64.     return 0;
  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. enter no of employees12
  90. Enter ID
  91. 1
  92. Enter name
  93. fdb
  94. Enter basic500
  95. Enter ID
  96. 2
  97. Enter name
  98. gfd
  99. Enter basic456
  100. Enter ID
  101. 56
  102. Enter name
  103. yfhhtr
  104. Enter basic848
  105. Enter ID
  106. 5
  107. Enter name
  108. hthtr
  109. Enter basic545
  110. Enter ID
  111. 7
  112. Enter name
  113. yr
  114. Enter basic546
  115. Enter ID
  116. 45
  117. Enter name
  118. yjryt
  119. Enter basic787
  120. Enter ID
  121. 5
  122. Enter name
  123. yjryjr
  124. Enter basic564
  125. Enter ID
  126. 25
  127. Enter name
  128. yfhytr
  129. Enter basic877
  130. Enter ID
  131. 55
  132. Enter name
  133. yjrd
  134. Enter basic666
  135. Enter ID
  136. 25
  137. Enter name
  138. htrhthtr
  139. Enter basic555
  140. Enter ID
  141. 5
  142. Enter name
  143. yjfyjr
  144. Enter basic785
  145. Enter ID
  146. 45
  147. Enter name
  148. fcfetr
  149. Enter basic321
  150.  
  151.  the employee details are
  152.  
  153. ID      Name    Basic   salary
  154. 1       fdb     500     1350
  155. 2       gfd     456     1292.8
  156. 56      yfhhtr  848     1802.4
  157. 5       hthtr   545     1408.5
  158. 7       yr      546     1409.8
  159. 45      yjryt   787     1023.1
  160. 5       yjryjr  564     733.2
  161. 25      yfhytr  877     1390.1
  162. 55      yjrd    666     1115.8
  163. 25      htrhthtr        555     971.5
  164. 5       yjfyjr  785     1270.5
  165. 45      fcfetr  321     667.3Press any key to continue
Advertisement
Add Comment
Please, Sign In to add comment