Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Michael Ceng
- // CIS 4100
- // LAB Extra Credit
- #include <iostream>
- using namespace std;
- class movieStats {
- private:
- double average, median, mode;
- double *arrayPtr;
- public:
- void pollStudents(int);
- double mean(int);
- };
- void movieStats::pollStudents(int students) {
- arrayPtr = nullptr; // do in constructor
- arrayPtr = new double[students];
- for (int i = 0; i < students; i++) {
- /*cout << "This value is located at: " << (arrayPtr + i) << endl;
- cout << *(arrayPtr + i) << endl;*/
- cout << "Please enter data for student " << i + 1 << ": \n";
- cin >> arrayPtr[i];
- }
- }
- double movieStats::mean(int students) {
- double temp = 0;
- for (int i = 0; i < students; i++) {
- temp += *(arrayPtr + i);
- }
- average = temp/students;
- cout << average << endl;
- return average;
- }
- int main()
- {
- movieStats a;
- int size;
- cout << "How many students? \n";
- cin >> size;
- a.pollStudents(size);
- a.mean(size);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement