Advertisement
asif_hayat

Sjjsjs

Jan 23rd, 2019
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.06 KB | None | 0 0
  1. #include<iostream>
  2. #include<math.h>
  3. #include<cstdlib>
  4. #include<string>
  5.  
  6. using namespace std;
  7. class person
  8.  
  9.  
  10. {
  11. protected:
  12. int id;
  13. string name;
  14. int age;
  15. string gender;
  16. public:
  17. void set_FieldName()
  18. {
  19.  
  20.  
  21. cout<<"NAME: ";
  22.  
  23. while(!(cin>>name))
  24. {
  25. cout << "Please enter a string! Try again: ";
  26. cin.clear ();
  27. cin.ignore (1000, '\n');
  28. }
  29. cout<<"GENDER: ";
  30.  
  31. while(!(cin>>gender))
  32. {
  33. cout << "Please enter a string! Try again: ";
  34. cin.clear ();
  35. cin.ignore (1000, '\n');
  36. }
  37.  
  38. cout<<"AGE: ";
  39. while(!(cin>>age))
  40. {
  41. cout << "Please enter a number! Try again: ";
  42. cin.clear ();
  43. cin.ignore (1000, '\n');
  44. }
  45. cout<<"ID: ";
  46.  
  47. while(!(cin>>id))
  48. {
  49. cout << "Please enter a number! Try again: ";
  50. cin.clear ();
  51. cin.ignore (1000, '\n');
  52. }
  53.  
  54. }
  55. void get_fieldname()
  56. {
  57. cout<<name<<"\t\t"<<id<<"\t\t"<<gender<<"\t"<<age<<endl;
  58. }
  59.  
  60.  
  61. void in_name()
  62. {
  63. cout<<"NAME: ";
  64. cin>>name;
  65. }
  66. string get_name()
  67. {
  68. return name;
  69. }
  70. void in_id()
  71. {
  72. cout<<"ID: " ;
  73. cin>>id;
  74. }
  75. int get_id()
  76. {
  77. return id;
  78. }
  79. void in_gender()
  80. {
  81. cout<<"GENDER: ";
  82. cin>>gender;
  83. }
  84. string get_gender()
  85. {
  86. return gender;
  87. }
  88. void in_age()
  89. {
  90. cout<<"AGE: ";
  91. cin>>age;
  92. }
  93. int get_age()
  94. {
  95. return age;
  96. }
  97.  
  98. };
  99. class owners: public person
  100. {
  101. private:
  102. double share;
  103. int bankacc;
  104. public:
  105. void addowner();
  106. void set_ownerfield()
  107. {
  108. set_FieldName();
  109. cout<<"SHARE: ";
  110. while(!(cin>>share))
  111. {
  112. cout << "Please enter a number! Try again: ";
  113. cin.clear ();
  114. cin.ignore (1000, '\n');
  115. }
  116. }
  117. void get_ownerfield()
  118. {
  119. cout<<name<<"\t\t "<<id<<"\t\t"<<gender<<"\t\t"<<age<<"\t "<<share<<endl;
  120.  
  121. }
  122. void in_share()
  123. {
  124. cout<<"PERCENT OF SHARE: ";
  125. cin>>share;
  126. }
  127. double get_share()
  128. {
  129. return share;
  130. }
  131. void in_bankacc()
  132. {
  133. cout<<"BALANCE OF ACCOUNT: " ;
  134. cin>>bankacc;
  135. }
  136. int get_bankacc()
  137. {
  138. return bankacc;
  139. }
  140. };
  141. class manager: public person
  142. {
  143. public:
  144.  
  145. int joiningdate;
  146. int salary;
  147. public:
  148.  
  149. void addmanager();
  150. void set_managerfield()
  151. {
  152. set_FieldName();
  153. cout<<"salary=";
  154. while(!(cin>>salary))
  155. {
  156. cout << "Please enter a number! Try again: ";
  157. cin.clear ();
  158. cin.ignore (1000, '\n');
  159. }
  160. }
  161. void get_managerfield()
  162. {
  163. cout<<name<<"\t\t "<<id<<"\t\t"<<gender<<"\t\t"<<age<<"\t "<<salary<<endl;
  164. }
  165. void in_joiningdate()
  166. {
  167. cout<<"JOINING DATE AT OFFICE: ";
  168. cin>>joiningdate;
  169. }
  170. int get_joinigdate()
  171. {
  172. return joiningdate;
  173. }
  174. void in_salary()
  175. {
  176. cout<<"MONTHLY SALARY: " ;
  177. cin>>salary;
  178. }
  179. int get_salary()
  180. {
  181. return salary;
  182. }
  183. };
  184. class salesman: public person
  185. {
  186. private:
  187. double salary;
  188. int joiningdate;
  189.  
  190.  
  191. public:
  192. void addsalesman();
  193. void set_salesmanfield()
  194. {
  195. set_FieldName();
  196. cout<<"SALARY: ";
  197. while(!(cin>>salary))
  198. {
  199. cout << "Please enter a number! Try again: ";
  200. cin.clear ();
  201. cin.ignore (1000, '\n');
  202. }
  203. cout<<"JOININGDATE: ";
  204. while(!(cin>>joiningdate))
  205. {
  206. cout << "Please enter a number! Try again: ";
  207. cin.clear ();
  208. cin.ignore (1000, '\n');
  209. }
  210. }
  211. void get_salesmanfield()
  212. {
  213. cout<<name<<"\t\t "<<id<<"\t\t"<<gender<<"\t\t"<<age<<"\t "<<salary<<"\t "<<joiningdate<<endl;
  214. }
  215. void in_salary()
  216. {
  217. cin>>salary;
  218. }
  219. double get_salary()
  220. {
  221. return salary;
  222. }
  223. void in_joiningdate()
  224. {
  225. cin>>joiningdate;
  226. }
  227. int get_joinigdate()
  228. {
  229. return joiningdate;
  230. }
  231.  
  232. };
  233.  
  234. void:: owners::addowner()
  235. {
  236. int b;
  237.  
  238. char redo;
  239. do{
  240.  
  241.  
  242. int i;
  243. int n=0;
  244. n++;
  245. set_ownerfield();
  246.  
  247. cout<<"\nOwner information has been added:"<<endl;
  248. cout<<"\n name id gender age share\n";
  249. cout<<"\n------- ------- -------- ------- ------\n";
  250. for(i=0;i<n;i++)
  251. {
  252. get_ownerfield();
  253. }
  254.  
  255. cout<<"do you want to add another:"<<endl;
  256. cin>>redo;
  257.  
  258. }
  259. while(redo=='y'||redo=='Y')
  260.  
  261.  
  262. ;}
  263. void::manager::addmanager()
  264. {
  265.  
  266. int i=0;
  267. char redo;
  268. do{
  269. int n=0;
  270. n++;
  271.  
  272.  
  273. set_managerfield();
  274.  
  275.  
  276. cout<<"\nmanager information has been added:"<<endl;
  277. cout<<"\n name id gender age salary \n"<<endl;
  278. cout<<"\n---------- --------- -------- ------- -------- \n"<<endl;
  279.  
  280.  
  281.  
  282. // cout<<e[i].get_fieldname()<<endl;
  283.  
  284. for(int i=0;i<n;i++){
  285.  
  286. get_managerfield();
  287.  
  288. }
  289. cout<<"do you want to add another:"<<endl;
  290. cin>>redo;
  291. }
  292.  
  293.  
  294.  
  295. while(redo=='y'||redo=='Y')
  296.  
  297.  
  298. ;}
  299. void::salesman::addsalesman()
  300. {
  301.  
  302. int i=0;
  303. char redo;
  304. do{
  305. int n=0;
  306. n++;
  307.  
  308. set_salesmanfield();
  309.  
  310. cout<<"\nsalesman information has been added:"<<endl;
  311. cout<<"\n name id gender age salary joiningdate \n"<<endl;
  312. cout<<"\n---------- ----- -------- ------- -------- --------- \n"<<endl;
  313.  
  314.  
  315.  
  316. // cout<<e[i].get_fieldname()<<endl;
  317.  
  318. for(int i=0;i<n;i++){
  319.  
  320. get_salesmanfield();
  321.  
  322. }
  323. cout<<"do you want to add another:"<<endl;
  324. cin>>redo;
  325. }
  326.  
  327.  
  328.  
  329. while(redo=='y'||redo=='Y')
  330.  
  331.  
  332. ;}
  333.  
  334.  
  335. class product
  336. {
  337. private:
  338. int id;
  339. string name;
  340. double price;
  341. string brand;
  342. public:
  343. void in_id()
  344. {
  345. cout<<"product identity: ";
  346. cin>>id;
  347. }
  348. int get_id()
  349. {
  350. return id;
  351. }
  352. void in_name()
  353. {
  354. cout<<"Enter the product name: ";
  355. cin>>name;
  356. }
  357. string get_name()
  358. {
  359. return name;
  360. }
  361. void in_price()
  362. {
  363. cout<<"price of product: ";
  364. cin>>price;
  365. }
  366. double get_price()
  367. {
  368. return price;
  369. }
  370. void in_brand()
  371. {
  372. cout<<"Brand of product: ";
  373. cin>>brand;
  374. }
  375. string get_brand()
  376. {
  377. return brand;
  378. }
  379. };
  380. class food: public product
  381. {
  382. private:
  383. double expdate;
  384. double quantity;
  385. public:
  386. void addfood();
  387. void in_expdate()
  388. {
  389. cout<<"Enter the product expdate: ";
  390. cin>>expdate;
  391. }
  392. double get_expdate()
  393. {
  394. return expdate;
  395.  
  396. }
  397. void in_quantity()
  398. {
  399. cout<<"Enter the product quantity: ";
  400. cin>>quantity;
  401. }
  402. double get_quantity()
  403. {
  404. return quantity;
  405. }
  406.  
  407. };
  408. class cosmetics: public product
  409. {
  410. private:
  411. double expdate;
  412. double quantity;
  413. public:
  414. void in_expdate()
  415. {
  416. cout<<"Enter the product expdate: ";
  417. cin>>expdate;
  418. }
  419. double get_expdate()
  420. {
  421. return expdate;
  422.  
  423. }
  424. void in_quantity()
  425. {
  426. cout<<"Enter the product quantity: ";
  427. cin>>quantity;
  428. }
  429. double get_quantity()
  430. {
  431. return quantity;
  432. }
  433.  
  434. };
  435. void::food::addfood()
  436. {
  437. int i=0;
  438.  
  439.  
  440. cout<<"\nFood information has been added:"<<endl;
  441. cout<<"\n name id price brand \n";
  442. cout<<"\n------- ------- -------- ------- \n";
  443.  
  444.  
  445. }
  446.  
  447.  
  448.  
  449. int main()
  450. {
  451. owners obj1[5];
  452. manager obj2[5];
  453. salesman obj3[5];
  454.  
  455. int c;
  456. char operation,ch;
  457.  
  458. do
  459. {
  460. cout<<"who do you want to know about?\n"<<endl;
  461. cout<<endl;
  462. cout<<endl;
  463.  
  464. cout<<" 1. About Owner"<<endl;
  465. cout<<" 2. About Manager"<<endl;
  466. cout<<" 3. About Salesman"<<endl;
  467. cout<<" 4. About product"<<endl;
  468. cout<<endl;
  469. cout<<"Enter the Serial number you desire: ";
  470. cin>>c;
  471. if(c==1)
  472. {
  473.  
  474. int x;
  475. char redo;
  476. {
  477. int o;
  478. cout<<"\nOwner information"<<endl;
  479. cout<<endl;
  480. cout<<"1.Add owner"<<endl;
  481. cout<<"2.Delete owner"<<endl;
  482. cout<<endl;
  483. cout<<"enter choice: ";
  484. cin>>o;
  485.  
  486.  
  487.  
  488. if(o==1)
  489. {
  490. cout<<"Enter the information of the owner:"<<endl;
  491. for(int i=0;i<5;i++)
  492. {
  493.  
  494.  
  495. obj1[i].addowner();
  496. }
  497. }
  498. else if(o==2)
  499. {
  500. cout<<"Delete information of owner"<<endl;
  501.  
  502. }
  503.  
  504. }
  505. }
  506.  
  507.  
  508.  
  509.  
  510. else if(c==2)
  511.  
  512. {
  513. int m;
  514. cout<<"\nManager information"<<endl;
  515. cout<<endl;
  516. cout<<"1.Add manager"<<endl;
  517. cout<<"2.Delete manager"<<endl;
  518. cout<<endl;
  519. cout<<"enter choice: "<<endl;
  520. cin>>m;
  521. if(m==1)
  522. {
  523. cout<<"Add manager information"<<endl;
  524. for(int i=0;i<5;i++)
  525. {
  526. obj2[i].addmanager();
  527. }
  528.  
  529. }
  530. else if(m==2)
  531. {
  532. cout<<"Delete information manager"<<endl;
  533. }
  534.  
  535. }
  536. else if(c==3)
  537. {
  538. cout<<"\nSalesman Information"<<endl;
  539. int s;
  540.  
  541. cout<<endl;
  542. cout<<"1.Add Salesman"<<endl;
  543. cout<<"2.Delete Salesman"<<endl;
  544. cout<<endl;
  545. cout<<"enter choice: "<<endl;
  546. cin>>s;
  547. if(s==1)
  548. {
  549. cout<<"Add salesman information"<<endl;
  550. for(int i=0;i<5;i++)
  551. {
  552. obj3[i].addsalesman();
  553. }
  554. }
  555. else if(s==2)
  556. {
  557. cout<<"delete information of salesman"<<endl;
  558. }
  559.  
  560. }
  561.  
  562. else if(c==4)
  563. {
  564. int p;
  565. cout<<"\nProduct information"<<endl;
  566. cout<<endl;
  567. cout<<"1.About Food"<<endl;
  568. cout<<"2. About Electronics"<<endl;
  569. cout<<"3.About cosmetics"<<endl;
  570. cout<<endl;
  571. cout<<"enter choice: "<<endl;
  572. cin>>p;
  573. if(p==1)
  574. {
  575. cout<<"\nFood information"<<endl;
  576. cout<<"1.Add food"<<endl;
  577. cout<<"2.Delete food"<<endl;
  578. }
  579. if(p==2)
  580. {
  581. cout<<"\nElectronics information"<<endl;
  582. cout<<"1.Add Electronics"<<endl;
  583. cout<<"2.Delete Electronics"<<endl;
  584. }
  585. if(p==3)
  586. {
  587. cout<<"\nCosmetics information"<<endl;
  588. cout<<"1.Add Cosmetics"<<endl;
  589. cout<<"2.Delete Cosmetics"<<endl;
  590. }
  591.  
  592. }
  593.  
  594.  
  595.  
  596. cout<<"\nDo u want to continue ";
  597. cin>>ch;
  598. }
  599. while(ch=='y'||ch=='Y')
  600.  
  601. ;return 0;
  602.  
  603. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement