Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <iterator>
- #include <string>
- using namespace std;
- class Student
- {
- private:
- string name;
- string facNum;
- vector<int>grades;
- double avarageGrades;
- public:
- Student() {
- name = "Nameless"; facNum = "noFacNumber";
- }
- Student(string getName, string getFacNum) {
- name = getName; facNum = getFacNum;
- }
- void add_grdae(int getGrade) {
- grades.push_back(getGrade);
- }
- double calculateAvarageGrades() {
- if (grades.size() != 0) {
- double aVg = 0;
- int numberOfElements = 0;
- for (int i = 0; i < grades.size(); i++){
- aVg += grades[i];
- //numberOfElements++;
- }
- return(aVg / grades.size());
- }
- else {
- cout << "There is no grades" << endl;
- }
- }
- void show()
- {
- cout << "Name:" << name << " " << "facuclty number: " << facNum << " ";
- if (grades.size() != 0) {
- cout << "average grades: " << calculateAvarageGrades() << endl;
- }
- else {
- cout << "There is no grades" << endl;
- }
- }
- };
- int main() {
- Student ob1,ob2("Kristian", "18621357");
- ob1.show();
- ob2.show();
- cout << endl;
- ob2.add_grdae(6);
- ob2.add_grdae(5);
- ob2.add_grdae(6);
- ob2.show();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement