Giter Site home page Giter Site logo

cplusplus's Introduction

// Cplusplus header #include #include using namespace std; class Student { private: string name; double TotalGrade; public: Student(string); string getName(); double getTotalGrade(); string getLetterGrade(); void AddGrade(double); double CalcAverage(); };// .cpp second part

#include "Student.h" #include #include using namespace std;

Student::Student(string n) { this->name = n; this->TotalGrade = 0; } string Student::getName() { return this->name; } double Student::getTotalGrade() { return this->TotalGrade; } void Student::AddGrade(double g) { this->TotalGrade += g; } double Student::CalcAverage() { this->TotalGrade = this->TotalGrade / 10; return this->TotalGrade; } string Student::getLetterGrade() { string letterGrade; double g = this->TotalGrade; if (g >= 100) letterGrade = "A+"; else if (g >= 93) letterGrade = "A"; else if (g >= 90 && g < 93) letterGrade = "A-"; else if (g >= 87 && g < 90) letterGrade = "B+"; else if (g >= 83 && g < 87) letterGrade = "B"; else if (g >= 80 && g < 83) letterGrade = "B-"; else if (g >= 77 && g < 80) letterGrade = "C+"; else if (g >= 73 && g < 77) letterGrade = "C"; else if (g >= 70 && g < 73) letterGrade = "C-"; else if (g >= 67 && g < 70) letterGrade = "D+"; else if (g >= 63 && g < 67) letterGrade = "D"; else if (g >= 60) letterGrade = "D-";

else
    letterGrade = "F";

return letterGrade;

} // initialization #include "Student.h" #include using namespace std; int main() { string name; double grade; string letter; int i = 1; cout << " ======================= Grade Book ======================" << endl; cout << endl; cout << " Enter student's name: "; getline(cin, name); cout << endl; Student s1(name); while (i <= 10) { cout << " Enter # " << i<< " " << s1.getName() << "'s grade : "; cin >> grade; s1.AddGrade(grade); cout << " ============================================================= "<< endl; cout << " Student's current grade is : " << s1.getTotalGrade() << endl; i++; } cout << " Student's total grade is : " << s1.getTotalGrade()<< endl; cout << " Student's average grade is : " << s1.CalcAverage() << endl; cout << " *************************************************************" << endl; cout << " >>>>> "<<s1.getName() << "'s FINAL LETTER GRADE is : " << s1.getLetterGrade() <<" <<<<< " << endl; cout << " *************************************************************" << endl;

}

cplusplus's People

Contributors

angelikakasia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.