Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class Student {
- vector<int> grades;
- string fn;
- string name;
- double average;
- public:
- Student(vector<int> g, string f, string n) {
- grades = g;
- fn = f;
- name = n;
- }
- Student() {
- grades = {
- 3,5,6,6,3,2,4,5
- };
- fn = "12345678";
- name = "I.Ivanov";
- average = 4;
- }
- void average() {
- int temp = 0;
- for (int i = 0; i < grades.size(); i++)
- {
- temp += grades[i];
- }
- average = temp / grades.size();
- cout << average << endl;
- }
- void addGrade(int g) {
- grades.push_back(g);
- }
- void addGrade(int g) {
- grades.push_back(g);
- }
- void print() {
- cout << "Grades:" << endl;
- for (int i = 0; i < grades.size(); i++) {
- cout << grades[i] << ' ';
- }
- }
- };
- int main()
- {
- vector<int> gr_1 = {
- 2,6,6,6,6,4,5,6,3,2,5
- };
- vector<int> gr_2 = {
- 6,6,6,6,2,3,4,5,5,5,3,4
- };
- Student ob1(gr_1, "72564332", "A.Stoyanov");
- ob1.average();
- ob1.print();
- }
Add Comment
Please, Sign In to add comment