1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
/*
Module7-Assignment7.cpp : main project file.
Written by Schuett, Hugh for Assignment 2, Module 2
10SS_INFO_1532_WW - C++ Programming II, Metropolitan Community College
Modified by Russell, for Assignment 2, Module 2, MCC, JUNE 2010
Modified by Russell, for Assignment 6, Module 6, MCC, JULY 2010
Modified by Russell, for Assignment 7, Module 7, MCC, AUG 2010
*/
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <string>
#include "Student.h"
/*
For this project you are going to take the last project, #6 (the grades program), and this time you are going to add operator overloading.
Remember the programming example at the end of the chapter is a great example of this.
Project Requirements:
<!--[if !supportLists]-->1. <!--[endif]-->A class object of this class will be all the information for one student.
<!--[if !supportLists]-->2. <!--[endif]-->You will have an array (4) of the objects, one element for each student.
<!--[if !supportLists]-->3. <!--[endif]-->You will overload the extraction operator (“>>”). The overloaded operator will then
perform all of the grade input for that individual. The code in your main will look like this: cin >> students[counter];
Where students is the array of objects and counter is the subscript.
<!--[if !supportLists]-->4. <!--[endif]-->You will overload the insertion operator (“<<”). The overloaded operator will then
perform all of the grade output for that individual. The code in your main will look like this: cout << students[counter]; Where
students is the array of objects and counter is the subscript.
*/
Student students[];
void gradeRecursion(int);
void displayOutput();
using namespace std;
int main ()
{
/*
name = new string[4];
//DEBUGGING
//cout << "\n\n " << &name << "\n\n";
//DEBUGGING
*name = "Freddie";
*(++name) = "Jane";
*(++name) = "Jonathan";
*(++name) = "Mary";
//DEBUGGING
//cout << "\n\n " << &name << "\n\n";
//DEBUGGING
name=name-3;
totalGPA = new double[4];
*/
Student students[3];
students[0].setName("Freddie");
students[1].setName("Jane");
students[2].setName("Jonathan");
students[3].setName("Mary");
gradeRecursion(3);
displayOutput();
cout << "\nPress any key to continue ..." << flush;
_getch();
/*
delete [] name;
delete [] totalGPA;
name = 0;
totalGPA = 0;
*/
return 0;
}
void gradeRecursion(int numGradesToGet)
{
if (numGradesToGet >= 0)
{
cin >> students[1];
system("cls");
if (numGradesToGet > 0)
{
gradeRecursion(numGradesToGet-1);
}
}
}
void displayOutput()
{
cout << fixed << showpoint << setprecision(3);
cout << setw(30) << left << "Student" << right << "GPA\n " << endl;
for( int x=3; x>=0; x-- )
{
//cout << students[x];
//cout << setw(30) << left << name[x] << right << totalGPA[x]/5 << endl;
}
}
|