Guest User

Untitled

a guest
Nov 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6. #include <string>
  7. #include <vector>
  8. using namespace std;
  9. class Student {
  10. vector<int> grades;
  11. string fn;
  12. string name;
  13. double average;
  14. public:
  15. Student(vector<int> g, string f, string n) {
  16. grades = g;
  17. fn = f;
  18. name = n;
  19. }
  20. Student() {
  21. grades = {
  22. 3,5,6,6,3,2,4,5
  23. };
  24. fn = "12345678";
  25. name = "I.Ivanov";
  26. average = 4;
  27. }
  28. void average() {
  29. int temp = 0;
  30. for (int i = 0; i < grades.size(); i++)
  31. {
  32. temp += grades[i];
  33. }
  34. average = temp / grades.size();
  35. cout << average << endl;
  36. }
  37. void addGrade(int g) {
  38. grades.push_back(g);
  39. }
  40. void addGrade(int g) {
  41. grades.push_back(g);
  42. }
  43. void print() {
  44. cout << "Grades:" << endl;
  45. for (int i = 0; i < grades.size(); i++) {
  46. cout << grades[i] << ' ';
  47. }
  48. }
  49. };
  50. int main()
  51. {
  52. vector<int> gr_1 = {
  53. 2,6,6,6,6,4,5,6,3,2,5
  54. };
  55. vector<int> gr_2 = {
  56. 6,6,6,6,2,3,4,5,5,5,3,4
  57. };
  58. Student ob1(gr_1, "72564332", "A.Stoyanov");
  59. ob1.average();
  60. ob1.print();
  61. }
Add Comment
Please, Sign In to add comment