Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. char converterFunction();
  6.  
  7. class StudentInfo{
  8.     private:
  9.     string myName[42];
  10.     char grades[5];
  11.     int hours[5];
  12.     float gpa;
  13.    
  14.     public:
  15.     string nameFunction();
  16.     float gpaFunction();
  17.     };
  18.  
  19.  
  20. char converterFunction(char grades[], int length = 5, int * convertedGrades)
  21.     {  
  22.     //cout << "Accessing private data through public" << endl;
  23.     for(int i = 0; i < length; i++){
  24.    
  25.     switch(grades[i])
  26.     {
  27.      case 'A':
  28.         convertedGrades[i] = 4;    
  29.      break;
  30.      case 'B':
  31.         convertedGrades[i] = 3;
  32.     break;
  33.     case 'C':
  34.         convertedGrades[i] = 2;
  35.     break;
  36.     case 'D':
  37.         convertedGrades[i] = 1;
  38.     break;
  39.     case 'F':
  40.         convertedGrades[i] = 0;
  41.     default:
  42.         cout<< "invalid grade!" << endl;
  43.      break;
  44.     }
  45.     }
  46.     }
  47.    
  48. float StudentInfo::gpaFunction()
  49.     {
  50.     int nombreCourses = 3;
  51.     int totalHours = 0;
  52.     int totalGradePoints = 0;
  53.     for(int i=0; i<nombreCourses; i++)
  54.     {
  55.     totalHours += hours;
  56.     }
  57.     for(int i = 0; i<nombreCourses; i++){
  58.     totalGradePoints += (hours * grades);
  59.     }
  60.  
  61.    gpa = (totalGradePoints)/totalHours;
  62.     cout<< " your  fake gpa is: " << gpa << endl;
  63.     }
  64.      
  65.  
  66. string StudentInfo::nameFunction()
  67.     {
  68.         //cout << "Accessing private data through public" << endl;
  69.         cout<< "enter your name: "<< endl;
  70.         cin >> myName;
  71.         return myName;
  72.     }
  73.  
  74. int main()
  75. {
  76.     class StudentInfo * bigPointer;
  77.     int numberOfStudents = 0;
  78.     int numberOfCourses = 3;
  79.  
  80.     cout << "please enter number of students"<< endl;
  81.     cin>> numberOfStudents;
  82.    
  83.    
  84.     bigPointer = new StudentInfo[numberOfStudents];
  85.    
  86.    
  87.     for(int i = 0; i < numberOfStudents; i++)
  88.         {
  89.         cout<< bigPointer->nameFunction() << endl;
  90.         for(int j = 0; j < numberOfCourses; j++)
  91.             {
  92.                 bigPointer->converterFunction();
  93.             }
  94.         bigPointer->gpaFunction();
  95.         }
  96.    
  97.  
  98.   cout<< "thats all folks!!!!"<< endl;
  99.       delete[] bigPointer;
  100.  
  101.   return 0;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement