Maruf_Hasan

Student

May 19th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. class Student
  6. {
  7. string name,rollno,section;
  8. double percentageofmark;
  9. public:
  10. Student()
  11. {
  12. name="";
  13. rollno="";
  14. section="";
  15. percentageofmark=0.0;
  16. }
  17. Student(string nam,string rol,string sec,double mark)
  18. {
  19. this->name=nam;
  20. this->rollno=rol;
  21. this->section=sec;
  22. this->percentageofmark=mark;
  23. }
  24. ~Student()
  25. {
  26. //cout<<"destructor"<<endl;
  27. }
  28. void input()
  29. {
  30. cout<<"Enter Name Roll Section and Mark"<<endl;
  31. string nam,rol,sec;
  32. double mark;
  33. cin>>nam>>rol>>sec;
  34. cin>>mark;
  35. name=nam;
  36. rollno=rol;
  37. section=sec;
  38. percentageofmark=mark;
  39. }
  40. void show()
  41. {
  42. cout<<"Name: "<<this->name<<endl;
  43. cout<<"Roll_No:"<<this->rollno<<endl;
  44. cout<<"Section: "<<this->section<<endl;
  45.  
  46. }
  47. void gradecalculator()
  48. {
  49. cout<<"Grade ";
  50. int x=this->percentageofmark;
  51. if(x>=90)
  52. {
  53. cout<<"A+"<<endl;
  54. }
  55. else if(x>=85)
  56. {
  57. cout<<"A"<<endl;
  58. }
  59. else if(x>=80)
  60. {
  61. cout<<"B+"<<endl;
  62. }
  63. else if(x>=75)
  64. {
  65. cout<<"B"<<endl;
  66. }
  67. else if(x>=70)
  68. {
  69. cout<<"C+"<<endl;
  70. }
  71. else if(x>=65)
  72. {
  73. cout<<"C"<<endl;
  74. }
  75. else if(x>=60)
  76. {
  77. cout<<"D+"<<endl;
  78. }
  79. else if(x>=50)
  80. {
  81. cout<<"D"<<endl;
  82. }
  83. else
  84. {
  85. cout<<"Fail"<<endl;
  86. }
  87. }
  88. };
  89. int main()
  90. {
  91. Student s1;
  92. s1.input();
  93. s1.show();
  94. s1.gradecalculator();
  95. cout<<"Second Object"<<endl;
  96. Student s2("shahriar","20-43565-1","b[28]",85);
  97. s2.show();
  98. s2.gradecalculator();
  99. return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment