Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int student_descriptoin();
  5. int result_maker();
  6. int gpa_maker(int roll);
  7.  
  8. class result
  9. {
  10. private:
  11. char name[100];
  12.  
  13. int serial_no;
  14. public:
  15. int roll;
  16. float cgpa=0;
  17. float credit=0;
  18. float gpa=0;
  19. void details(int i)
  20. {
  21. serial_no=i+1;
  22. cout<<"\nname:";
  23. cin>>name;
  24. cout<<"roll:";
  25. cin>>roll;
  26.  
  27. }
  28. void print_result()
  29. {
  30. cout<<"serial no:"<<serial_no<<endl;
  31. cout<<"name:"<<name<<endl;
  32.  
  33. cout<<"roll:"<<roll<<endl;
  34.  
  35. cout<<"cgpa:"<<cgpa<<endl;
  36. }
  37.  
  38. };
  39. result ob[10000];
  40. static int n;
  41.  
  42. int main()
  43. {
  44. int i;
  45. student_descriptoin();
  46. result_maker();
  47.  
  48.  
  49. cout<<"\nlist of result:\n";ft
  50. for(i=0;i<n;i++)
  51. ob[i].print_result();
  52.  
  53.  
  54. }
  55.  
  56. int student_descriptoin()
  57. {
  58. int i;
  59. cout<<"\nHOW MANY STUDENTS:";
  60. cin>>n;
  61. cout<<"\nput students details:\n";
  62. for(i=0;i<n;i++)
  63. {
  64. ob[i].details(i);
  65. }
  66.  
  67. }
  68. int result_maker()
  69. {
  70. int rol,i;
  71. cout<<"\n\nINPUR RESULT:\n";
  72. for(i=0;i<n;i++)
  73. {
  74. cout<<"put roll:";
  75. cin>>rol;
  76. gpa_maker(rol);
  77.  
  78. }
  79.  
  80. }
  81. int gpa_maker(int rol)
  82. {
  83. int no,x,i;
  84. float a,c,gpa,sum=0,credit=0;
  85. cout<<"\nput the no. of sub:";
  86. cin>>no;
  87. for(i=1;i<=no;i++)
  88. {
  89. cout<<"subject no. "<<i<<":"<<endl;
  90. cout<<"gpa:";
  91. cin>>a;
  92. cout<<"credit:";
  93. cin>>c;
  94. sum=sum+a*c;
  95. credit=credit+c;
  96. }
  97. for(i=0;i<n;i++)
  98. {
  99. x=ob[i].roll;
  100. if(rol==x)
  101. {
  102. ob[i].gpa+=sum;
  103. ob[i].credit+=credit;
  104. ob[i].cgpa=ob[i].gpa/ob[i].credit;
  105. }
  106. }
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement