Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- char converterFunction();
- class StudentInfo{
- private:
- string myName[42];
- char grades[5];
- int hours[5];
- float gpa;
- public:
- string nameFunction();
- float gpaFunction();
- };
- char converterFunction(char grades[], int length = 5, int * convertedGrades)
- {
- //cout << "Accessing private data through public" << endl;
- for(int i = 0; i < length; i++){
- switch(grades[i])
- {
- case 'A':
- convertedGrades[i] = 4;
- break;
- case 'B':
- convertedGrades[i] = 3;
- break;
- case 'C':
- convertedGrades[i] = 2;
- break;
- case 'D':
- convertedGrades[i] = 1;
- break;
- case 'F':
- convertedGrades[i] = 0;
- default:
- cout<< "invalid grade!" << endl;
- break;
- }
- }
- }
- float StudentInfo::gpaFunction()
- {
- int nombreCourses = 3;
- int totalHours = 0;
- int totalGradePoints = 0;
- for(int i=0; i<nombreCourses; i++)
- {
- totalHours += hours;
- }
- for(int i = 0; i<nombreCourses; i++){
- totalGradePoints += (hours * grades);
- }
- gpa = (totalGradePoints)/totalHours;
- cout<< " your fake gpa is: " << gpa << endl;
- }
- string StudentInfo::nameFunction()
- {
- //cout << "Accessing private data through public" << endl;
- cout<< "enter your name: "<< endl;
- cin >> myName;
- return myName;
- }
- int main()
- {
- class StudentInfo * bigPointer;
- int numberOfStudents = 0;
- int numberOfCourses = 3;
- cout << "please enter number of students"<< endl;
- cin>> numberOfStudents;
- bigPointer = new StudentInfo[numberOfStudents];
- for(int i = 0; i < numberOfStudents; i++)
- {
- cout<< bigPointer->nameFunction() << endl;
- for(int j = 0; j < numberOfCourses; j++)
- {
- bigPointer->converterFunction();
- }
- bigPointer->gpaFunction();
- }
- cout<< "thats all folks!!!!"<< endl;
- delete[] bigPointer;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement