Maruf_Hasan

Sazed project

Jun 22nd, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.88 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<vector>
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6.  
  7. int n;
  8.  
  9. int stoi(string s)
  10. {
  11. int len=s.size();
  12. int num=0;
  13. for(int i=len-1; i>=0; i--)
  14. {
  15. num+=(s[i]-48);
  16. num*=10;
  17. }
  18. num/=10;
  19. return num;
  20.  
  21. }
  22.  
  23. class student_num
  24. {
  25. public:
  26. int total_num=0;
  27. string roll5;
  28.  
  29. student_num()
  30. {
  31. total_num=0;
  32. roll5="1707030";
  33. }
  34.  
  35. student_num(string roll9)
  36. {
  37. roll5=roll9;
  38. fstream fin;
  39. fin.open("Lab_marks.csv",ios::in);
  40.  
  41. int count=0,total=0;
  42. vector<string>row1;
  43. string word,line;
  44.  
  45. while(!fin.eof())
  46. {
  47. row1.clear();
  48. getline(fin,line);
  49. stringstream s(line);
  50.  
  51. while(getline(s,word,','))
  52. {
  53. row1.push_back(word);
  54.  
  55. }
  56. int row_size=row1.size();
  57. int num=0;
  58.  
  59. if(row1[0]==roll9)
  60. {
  61.  
  62. for(int i=1; i<row_size; i++)
  63. {
  64.  
  65. num = stoi(row1[i]);
  66. total+=num;
  67. }
  68.  
  69.  
  70.  
  71.  
  72. }
  73.  
  74.  
  75. count++;
  76. if(count==30)break;
  77.  
  78.  
  79. }
  80.  
  81. fin.close();
  82. total_num=total;
  83. }
  84.  
  85.  
  86. student_num operator+(student_num std2)
  87. {
  88. student_num std3;
  89. if(this->total_num>=std2.total_num)
  90. {
  91. std3.total_num=this->total_num;
  92. std3.roll5=this->roll5;
  93.  
  94. }
  95. else
  96. {
  97. std3.total_num=std2.total_num;
  98. std3.roll5=std2.roll5;
  99. }
  100. return std3;
  101. }
  102. friend class teacher;
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110. };
  111.  
  112.  
  113. class student
  114. {
  115. public:
  116. int cost,amount;
  117. string pass_new,name,day,time,ename,cname,sroll,sname,sphn,sirname,sirdeg,sirphn,roll;
  118. string name_new;
  119.  
  120. void show_all()
  121. {
  122. fstream fin;
  123. fin.open("Lab_marks.csv",ios::in);
  124.  
  125. int number,number2,count=0,total=0;
  126. vector<string>row1;
  127. string word,line,roll2;
  128. cout<<"enter a roll ";
  129. cin>>roll2;
  130. while(!fin.eof())
  131. {
  132. row1.clear();
  133. getline(fin,line);
  134. stringstream s(line);
  135.  
  136. while(getline(s,word,','))
  137. {
  138. row1.push_back(word);
  139.  
  140. }
  141. int row_size=row1.size();
  142. int num=0;
  143.  
  144. if(row1[0]==roll2)
  145. {
  146. cout<<"Number of the student:\n";
  147. for(int i=1; i<row_size; i++)
  148. {
  149. cout<<"Lab "<<i<<": "<<row1[i]<<endl;
  150. num = stoi(row1[i]);
  151. total+=num;
  152. }
  153. cout<<"Total Marks: "<<total<<endl;
  154. printf("Average Marks: %.2lf\n",(((double)total)/(row_size-1)));
  155. printf("Rate of Performance: %.2lf",((((double)total)/(10*(row_size-1)))*100));
  156. cout<<"%\n";
  157.  
  158. }
  159.  
  160.  
  161. count++;
  162. if(count==30)break;
  163.  
  164.  
  165. }
  166.  
  167. fin.close();
  168.  
  169. }
  170. void show_all(string roll2)
  171. {
  172. fstream fin;
  173. fin.open("Lab_marks.csv",ios::in);
  174.  
  175. int number,number2,count=0,total=0;
  176. vector<string>row1;
  177. string word,line;
  178.  
  179. while(!fin.eof())
  180. {
  181. row1.clear();
  182. getline(fin,line);
  183. stringstream s(line);
  184.  
  185. while(getline(s,word,','))
  186. {
  187. row1.push_back(word);
  188.  
  189. }
  190. int row_size=row1.size();
  191. int num=0;
  192.  
  193. if(row1[0]==roll2)
  194. {
  195. cout<<"Number of the student:\n";
  196. for(int i=1; i<row_size; i++)
  197. {
  198. cout<<"Lab "<<i<<": "<<row1[i]<<endl;
  199. num = stoi(row1[i]);
  200. total+=num;
  201. }
  202. cout<<"Total Marks: "<<total<<endl;
  203. printf("Average Marks: %.2lf\n",(((double)total)/(row_size-1)));
  204. printf("Rate of Performance: %.2lf",((((double)total)/(10*(row_size-1)))*100));
  205. cout<<"%\n";
  206. }
  207.  
  208.  
  209. count++;
  210. if(count==30)break;
  211.  
  212.  
  213. }
  214.  
  215. fin.close();
  216.  
  217. }
  218.  
  219.  
  220.  
  221. void input_marks()
  222. {
  223. fstream fin,fout;
  224. fin.open("Lab_marks.csv",ios::in);
  225. fout.open("Lab_marks2.csv",ios::out | ios::app);
  226.  
  227. int number,number2,count=0;
  228. vector<string>row1;
  229. string word,line;
  230.  
  231. while(!fin.eof())
  232. {
  233. row1.clear();
  234. getline(fin,line);
  235. stringstream s(line);
  236.  
  237. while(getline(s,word,','))
  238. {
  239. row1.push_back(word);
  240. fout<<word<<",";
  241. }
  242. cout<<"Input Number for roll: "<<row1[0]<<endl;
  243.  
  244. cin>>number;
  245. fout<<number<<"\n";
  246. count++;
  247. if(count==30)break;
  248.  
  249.  
  250. }
  251. fin.close();
  252. fout.close();
  253. remove("Lab_marks.csv");
  254. rename("Lab_marks2.csv","Lab_marks.csv");
  255.  
  256.  
  257.  
  258.  
  259.  
  260. }
  261.  
  262.  
  263.  
  264. virtual void file_read()
  265. {
  266. s:
  267. cout<<"PLEASE ENTER YOUR ID\n";
  268. cin>>roll;
  269. t:
  270. cout<<"PLEASE ENTER YOUR PASSWORD\n";
  271. string pass;
  272. cin>>pass;
  273. cout<<endl;
  274. ifstream inf("user_pass.txt");
  275. int flag=0;
  276. for(int i=0; i<30; i++)
  277. {
  278. inf>>name_new;
  279. inf>>pass_new;
  280. if(name_new==roll && pass_new==pass)
  281. {
  282. cout<<"\t\t********WELCOME "<<roll<<"******"<<endl;
  283. d:
  284. cout<<"\t1.show routine\n\t2.show equipment\n\t3.show mark\n\t4.show student list\n\t5.show teacher list\n\t6.log out\n";
  285. cout<<"enter your choice\n";
  286. int e;
  287. cin>>e;
  288. if(e==1)
  289. {
  290. show_routine();
  291. cout<<endl;
  292. goto d;
  293.  
  294.  
  295. }
  296. if(e==2)
  297. {
  298. show_equipment();
  299. cout<<endl;
  300. goto d;
  301. }
  302. if(e==3)
  303. {
  304. show_all(roll);
  305. cout<<endl;
  306. goto d;
  307. }
  308. if(e==4)
  309. {
  310. show_slist();
  311. cout<<endl;
  312. goto d;
  313. }
  314. if(e==5)
  315. {
  316. show_sirlist();
  317. cout<<endl;
  318. goto d;
  319.  
  320. }
  321. if(e==6)
  322. {
  323. cout<<"\t*******THANK YOU FOR USING THIS APPLICATION*******\n";
  324. return ;
  325. }
  326.  
  327.  
  328. flag=1;
  329.  
  330. }
  331. else if(name_new==roll && pass_new!=pass)
  332. {
  333. cout<<"Invalid Pass"<<endl;
  334. goto t;
  335. flag=1;
  336. }
  337.  
  338. }
  339. if(!flag)
  340. {
  341. cout<<"Invalid ID"<<endl;
  342. goto s;
  343. }
  344.  
  345.  
  346. inf.close();
  347. }
  348.  
  349.  
  350.  
  351. void creat_routine()
  352. {
  353. ofstream outf("routine.txt");
  354.  
  355. for(int i=0; i<4; i++)
  356. {
  357. cout<<"group:";
  358. cin>>name;
  359.  
  360.  
  361. outf<<name<<" ";
  362.  
  363. cout<<"day:";
  364.  
  365. cin>>day;
  366. outf<<day<<" ";
  367. cout<<"time:";
  368. cin>>time;
  369. outf<<time<<endl;
  370. }
  371. outf.close();
  372. }
  373. void show_routine()
  374. {
  375. ifstream inf("routine.txt");
  376. for(int i=0; i<4; i++)
  377. {
  378. inf>>name;
  379. inf>>day;
  380. inf>>time;
  381.  
  382. cout<<"\t"<<name<< " "<<day<<" "<<time<<endl;
  383. }
  384. inf.close();
  385.  
  386. }
  387. void add_equipment()
  388. {
  389. fstream outf;
  390. outf.open("equipment.txt",ios::out | ios::app);
  391. cout<<"add how many?";
  392.  
  393. cin>>n;
  394.  
  395.  
  396. for(int i=0; i<n; i++)
  397. {
  398. cout<<"name of equipment:";
  399. cin>>ename;
  400.  
  401.  
  402. outf<<ename<<"\t ";
  403.  
  404. cout<<"company name:";
  405.  
  406. cin>>cname;
  407. outf<<cname<<" \t";
  408. cout<<"amount:";
  409. cin>>amount;
  410. outf<<amount<<"\t ";
  411. cout<<"price per equipment:";
  412. cin>>cost;
  413. cout<<endl;
  414. outf<<cost<<endl;
  415. }
  416. outf.close();
  417. }
  418. void show_equipment()
  419.  
  420. {
  421. /* cout<<"\titem\t company amount price\n";
  422. ifstream inf("equipment.txt");
  423. string show;
  424. while(!inf.eof())
  425. {
  426. getline(inf,show);
  427. cout<<"\t"<<show<<" "<<endl;
  428.  
  429. }
  430. inf.close();*/system("FB_IMG_1542631341519.jpg");
  431. }
  432. void student_list()
  433. {
  434. ofstream outf("studentlist.txt");
  435.  
  436.  
  437. for(int i=0; i<30; i++)
  438. {
  439. cout<<"roll:";
  440. cin>>sroll;
  441.  
  442.  
  443. outf<<sroll<<" ";
  444.  
  445. cout<<"student name:";
  446.  
  447. cin>>sname;
  448. outf<<sname<<" ";
  449. cout<<"phone no:";
  450. cin>>sphn;
  451. outf<<sphn<<endl;
  452.  
  453. }
  454. outf.close();
  455. }
  456. void show_slist()
  457.  
  458. {
  459. cout<<"\tROLL\t NAME\t\t PHONE NUMBER\n";
  460. cout<<endl;
  461. ifstream inf("studentlist.txt");
  462. for(int i=0; i<30; i++)
  463. {
  464. inf>>sroll;
  465. inf>>sname;
  466. inf>>sphn;
  467.  
  468. cout<<"\t"<<sroll<< " "<<sname<<" "<<sphn<<endl;
  469. }
  470. inf.close();
  471. }
  472.  
  473. void teacher_list()
  474. {
  475. ofstream outf("teacherlist.txt");
  476.  
  477.  
  478. for(int i=0; i<2; i++)
  479. {
  480. cout<<"name:";
  481. cin>>sirname;
  482.  
  483.  
  484. outf<<sirname<<" ";
  485.  
  486. cout<<"designation:";
  487.  
  488. cin>>sirdeg;
  489. outf<<sirdeg<<" ";
  490. cout<<"phone no:";
  491. cin>>sirphn;
  492. outf<<sirphn<<endl;
  493.  
  494. }
  495. outf.close();
  496. }
  497. void show_sirlist()
  498.  
  499. {
  500. cout<<"\tname\t\t designation\t PHONE NUMBER\n";
  501. cout<<endl;
  502. ifstream inf("teacherlist.txt");
  503. for(int i=0; i<2; i++)
  504. {
  505. inf>>sirname;
  506. inf>>sirdeg;
  507. inf>>sirphn;
  508.  
  509. cout<<"\t"<<sirname<< " "<<sirdeg<<" "<<sirphn<<endl;
  510. }
  511. inf.close();
  512. }
  513.  
  514.  
  515. };
  516. class
  517. teacher : public student
  518. {
  519. public:
  520. int n;
  521.  
  522. void compare()
  523. {
  524. student_num std3;
  525. string x,y;
  526. cout<<"\nEnter 1st roll: ";
  527. cin>>x;
  528. cout<<"\nEnter 2nd roll: ";
  529. cin>>y;
  530. student_num std1(x),std2(y);
  531. std3=std1+std2;
  532. cout<<"\nThe Better performing Student is "<<std3.roll5<<" consisting of total marks "<<std3.total_num<<endl;
  533.  
  534.  
  535.  
  536. }
  537.  
  538.  
  539.  
  540. void file_read()
  541. {
  542. s:
  543. cout<<"Please Enter your ID Sir\n";
  544. string roll;
  545. cin>>roll;
  546. t:
  547. cout<<"Password Please\n";
  548. string pass;
  549. cin>>pass;
  550. cout<<endl;
  551. ifstream inf("user_pass.txt");
  552. int flag=0;
  553. for(int i=0; i<2; i++)
  554. {
  555. inf>>name_new;
  556. inf>>pass_new;
  557. if(name_new==roll && pass_new==pass)
  558. {
  559. cout<<"\t*********WELCOME "<<" "<<roll<<"*********"<<endl;
  560. d:
  561. cout<<"\t1.create routine\n\t2.show routine\n\t3.create student list\n\t4.show student list\n\t5.create teacher list\n\t6.show teacher lista\n\t7.add mark\n\t8.show mark \n\t9.add equipment\n\t10.show equipment\n\t11.Compare Student\n\t12.log out\n";
  562. cout<<"enter your choice\n";
  563. int e;
  564. cin>>e;
  565. if(e==1)
  566. {
  567. creat_routine();
  568. goto d;
  569. }
  570. if(e==2)
  571. {
  572. show_routine();
  573. cout<<endl;
  574. goto d;
  575.  
  576. }
  577. if(e==3)
  578. {
  579. student_list();
  580. cout<<endl;
  581. goto d;
  582.  
  583. }
  584. if(e==4)
  585. {
  586. show_slist();
  587. cout<<endl;
  588. goto d;
  589.  
  590. }
  591. if(e==5)
  592. {
  593. teacher_list();
  594. cout<<endl;
  595. goto d;
  596.  
  597. }
  598.  
  599. if(e==6)
  600. {
  601. show_sirlist();
  602. cout<<endl;
  603. goto d;
  604.  
  605. }
  606. if(e==7)
  607. {
  608. input_marks();
  609. cout<<endl;
  610. goto d;
  611. }
  612.  
  613. if(e==8)
  614. {
  615. show_all();
  616. cout<<endl;
  617. goto d;
  618. }
  619. if(e==9)
  620. {
  621. add_equipment();
  622. cout<<endl;
  623.  
  624. goto d;
  625. }
  626.  
  627. if(e==10)
  628. {
  629. show_equipment();
  630. cout<<endl;
  631. goto d;
  632. }
  633. if(e==11)
  634. {
  635. compare();
  636. cout<<endl;
  637. goto d;
  638. }
  639. if(e==12)
  640. {
  641. cout<<"\t******THANK YOU FOR USING THIS APPLICATION******\n";
  642. return;
  643. }
  644. flag=1;
  645. }
  646. else if(name_new==roll && pass_new!=pass)
  647. {
  648. cout<<"Invalid Pass"<<endl;
  649. goto t;
  650. flag=1;
  651. }
  652.  
  653. }
  654. if(!flag)
  655. {
  656. cout<<"Invalid ID"<<endl;
  657. goto s;
  658. }
  659. inf.close();
  660. }
  661. };
  662.  
  663. int main()
  664. {
  665. student b,*bptr;
  666. teacher a;
  667. cout<<"\t\t**************************************************************\n";
  668. cout<<"\t\t\t*************************************************\n";
  669. cout<<"\t\t\t\t***************************\n";
  670. cout<<endl;
  671. cout<<"\t\t\t\tWELCOME TO CPP LAB MANAGEMENT\t\n";
  672. cout<<endl;
  673. cout<<"\t1.LOG IN\n\t2.EXIT";
  674. int c;
  675. cout<<endl;
  676. cout<<"Enter your choice\n";
  677. cin>>c;
  678. if(c==1)
  679. {
  680. cout<<"1.STUDENT\n2.TEACHER\n";
  681. int x;
  682. cin>>x;
  683. if(x==1)
  684. {
  685. bptr=&b;
  686. bptr->file_read();
  687. }
  688. else
  689. {
  690. bptr=&a;
  691. bptr->file_read();
  692. }
  693. }
  694. return 0;
  695. }
Advertisement
Add Comment
Please, Sign In to add comment