Created
June 14, 2013 05:40
-
-
Save sprintr/5779698 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| #include <cstdlib> | |
| using namespace std; | |
| class Student | |
| { | |
| public: | |
| void getData() { | |
| cout << "Enter your roll number: " << endl; | |
| cin >> rollNo; | |
| cout << "Enter your full name: " << endl; | |
| cin >> name; | |
| } | |
| private: | |
| int rollNo; | |
| string name; | |
| }; | |
| class Marks : public Student | |
| { | |
| public: | |
| void getMarks() { | |
| cout << "Enter your marks of 1st Subject: " << endl; | |
| cin >> m1; | |
| cout << "Enter your marks of 2nd Subject: " << endl; | |
| cin >> m2; | |
| cout << "Enter your marks of 3rd Subject: " << endl; | |
| cin >> m3; | |
| } | |
| void display() { | |
| percentage = ((m1 + m2 + m3) / 300.0) * 100.0; | |
| cout << "Your percentage is: " << percentage << endl; | |
| } | |
| private: | |
| int m1, m2, m3; | |
| double percentage; | |
| }; | |
| int main() | |
| { | |
| Marks s1; | |
| s1.getData(); | |
| s1.getMarks(); | |
| s1.display(); | |
| system("pause"); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment