oop[1] - 0.4 * getProjAvg ()+ 0.6 * getExamAvg (); } void...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <fstream> using namespace std ; class Student{ // Declaration of the class Student private : // Data associated with Student char name [ 50 ]; float projects [ 8 ]; float exams [ 3 ]; int UFID [ 8 ]; int sizename ; public : //Methods associated with Student Student( char a[], float b[], float c[], int d[]); Student(); float getExamAvg(); float getProjAvg(); float getGrade(); void getName(); void getUFID(); void printReport(); void printFileReport(); }; //Implementation of the methods Student :: Student (){ for ( int i= 0 ;i< 8 ;i++) projects[i]= 0 ; for ( int i= 0 ;i< 3 ;i++) exams[i]= 0 ; for ( int i= 0 ;i< 8 ;i++) UFID[i]= 0 ; for ( int i= 0 ;i< 50 ;i++) name[i]= '.' ; } Student :: Student ( char a[], float b[], float c[], int d[]){ int k= 0 ; do { name[k]=a[k]; k++; } while (a[k]!= '.' ); sizename=k; for ( int i= 0 ;i< 8 ;i++){ projects[i]=b[i]; UFID[i]=d[i]; } for ( int i= 0 ;i< 3 ;i++) exams[i]=c[i]; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
float Student ::getExamAvg(){ float sum= 0 ; for ( int i= 0 ;i< 3 ;i++) sum+=exams[i]; return sum/ 3 ; } float Student ::getProjAvg(){ float sum= 0 ; for ( int i= 0 ;i< 8 ;i++) sum+=projects[i]; return sum/ 8 ; } float Student ::getGrade(){ return
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0.4 * getProjAvg ()+ 0.6 * getExamAvg (); } void Student ::getUFID(){ cout << "The UFID is " ; for ( int i= ;i< 8 ;i++) cout << UFID[i]; cout << endl; } void Student ::getName(){ cout << "The name is " ; for ( int i= ;i<sizename;i++) cout << name[i]; cout << endl; } void Student ::printReport(){ getName (); getUFID (); cout << "The average in the class is: " << getGrade () << endl; } // A main for practice int main () { float proj[ 8 ]={ 70 , 90 , 100 , 60 , 80 , 100 , 90 , 70 }; float ex[ 3 ]={ 91 , 80 , 86 }; int id [ 8 ]={ 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 }; Student Chrys( "Chrysafis Vogiatzis." , proj, ex, id ); Student Stu( "Stuart." , proj , ex, id ); Chrys. printReport (); Student classroll[ 150 ]; // an array of objects //as compared to the simple arrays we have seen up to now. . classroll[ 100 ]. printReport (); cin . get (); cin . get (); return ; }...
View Full Document

This note was uploaded on 09/27/2011 for the course CGS 2421 taught by Professor Onal during the Spring '09 term at University of Florida.

Page1 / 3

oop[1] - 0.4 * getProjAvg ()+ 0.6 * getExamAvg (); } void...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online