Question

In: Computer Science

In C++ and their need to be 3 files please Instructions In this lab, you will...

In C++ and their need to be 3 files please

Instructions

In this lab, you will modify the Student class you created in a previous lab. You will modify one new data member which will be a static integer data member. Call that data member count. You also add a static method to the Student class that will display the value of count with a message indicating what the value represents, meaning I do not want to just see a value printed to the screen.

Change main so that it calls this new method towards the end of the program. Call the method using the static syntax; do not use one of the instances of the Student class.

You will also need to change the Student constructor so that it increments the new data member you added, count. In your post explain why you get the value it displays.

Download Source Lab 7 Files:

File 1.) Source.cpp

#include

#include "Student.h"

using namespace std;

int main()

{

Student rich(2);

rich.DisplayStudent();

Student mary(3);

mary.DisplayStudent();

return 0;

}

File 2.) Student.cpp

#include "Student.h"

Student::Student(int numGrades)

{

quanity = numGrades;

grades = new int[numGrades];

name = "rich";

grades[0] = 88;

grades[1] = 96;

}

Student::~Student()

{

delete[] grades;

}

void Student::DisplayStudent()

{

cout << "Grades for " << name << endl;

for (int index = 0; index < quanity; index++)

{

cout << *(grades + index) << endl;

}

}

File 3.) Student.h #pragma once

#include

#include

using namespace std;

class Student

{

public: Student(int numGrades);

~Student();

void DisplayStudent();

private: string name;

int* grades;

int quanity;

};

Solutions

Expert Solution

If you have any doubts, please give me comment...

Student.h

#pragma once

#include<iostream>

#include<string>

using namespace std;

class Student

{

public:

    Student(int numGrades);

    ~Student();

    void DisplayStudent();

    static int getCount();

private:

    static int count;

    string name;

    int *grades;

    int quanity;

};

Student.cpp

#include "Student.h"

int Student::count = 0;

Student::Student(int numGrades)

{

    quanity = numGrades;

    grades = new int[numGrades];

    name = "rich";

    grades[0] = 88;

    grades[1] = 96;

    count++;

}

Student::~Student()

{

    delete[] grades;

}

void Student::DisplayStudent()

{

    cout << "Grades for " << name << endl;

    for (int index = 0; index < quanity; index++)

    {

        cout << *(grades + index) << endl;

    }

}

int Student::getCount(){

    return count;

}

Source.cpp

#include<iostream>

#include "Student.h"

using namespace std;

int main()

{

    Student rich(2);

    rich.DisplayStudent();

    Student mary(3);

    mary.DisplayStudent();

    cout<<"Number of students: "<<Student::getCount()<<endl;

    return 0;

}


Related Solutions

Instructions (In C++ Please) Verification This programming lab makes use of an array of characters. The...
Instructions (In C++ Please) Verification This programming lab makes use of an array of characters. The program will validate the characters in the array to see if they meets a set of requirements. Requirements: Must be at least 6 characters long (but not limited to 6, can be greater) Contains one upper case letter Contains one lower case letter Contains one digit Complete the code attached. Must use pointer while checking the characters. Download Source Lab 3 File: #include using...
C++ question. Need all cpp and header files. Part 1 - Polymorphism problem 3-1 You are...
C++ question. Need all cpp and header files. Part 1 - Polymorphism problem 3-1 You are going to build a C++ program which runs a single game of Rock, Paper, Scissors. Two players (a human player and a computer player) will compete and individually choose Rock, Paper, or Scissors. They will then simultaneously declare their choices and the winner is determined by comparing the players’ choices. Rock beats Scissors. Scissors beats Paper. Paper beats Rock. The learning objectives of this...
I need this in java on textpad. There are two files, both have instructions in them...
I need this in java on textpad. There are two files, both have instructions in them on what to add in the code. They are posted below. public class MyArrayForDouble { double[] nums; int numElements; public MyArrayForDouble() { // Constructor. automatically called when creating an instance numElements = 0; nums = new double[5]; } public MyArrayForDouble(int capacity) { // Constructor. automatically called when creating an instance numElements = 0; nums = new double[capacity]; } public MyArrayForDouble(double[] nums1) { nums =...
in c++ please In this program you are going to have several files to turn in...
in c++ please In this program you are going to have several files to turn in (NOT JUST ONE!!) hangman.h – this is your header file – I will give you a partially complete header file to start with. hangman.cpp – this is your source file that contains your main function functions.cpp – this is your source file that contains all your other functions wordBank.txt – this is the file with words for the game to use.  You should put 10...
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL...
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL R commands you used to reach your answers in a word or pdf document. Also, report everything you are asked to do so. Problem 3 : In lab lecture notes and demo code, I simulated random samples from Exp(1) to verify classical central limit theorem numerically. I also stressed that no matter what type of random samples you use, the standardized partial sum Sn...
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL...
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL R commands you used to reach your answers in a word or pdf document. Also, report everything you are asked to do so. Problem 1 : Consider a binomial random variable X ∼ Bin(100, 0.01). 1. Report P(X = 7), P(X = 8), P(X = 9), try to use one ONE R command to return all these three values. 2. Find the probability P(0...
In this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A...
In this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A test driver for testing the class defined in the other 2 files. You can name your file in the way you like. Remember it must be a .cpp file. In DateType.h file, type these lines: // To declare a class for the Date ADT // This is the header file DateType.h class DateType { public: void Initialize(int newMonth, int newDay, int newYear); int GetYear()...
C++ Funcion For this lab you need to write a program that will read in two...
C++ Funcion For this lab you need to write a program that will read in two values from a user and output the greatest common divisor (using Euclidean algorithm) to a file. You will also need to demonstrate using ostream and ostringstream by creating 2 functions to output your print heading: one that uses ostream and the other uses ostringstream. Using ostream and ostringstream Write two PrintHeader functions that will allow you to output to the screen and to an...
c++ code please show differint h files and cpp files 2.3 Task 1 You are working...
c++ code please show differint h files and cpp files 2.3 Task 1 You are working as a programmer designing a vehicular system for the newly forced Edison Arms Company. The weapon system is a generic weapon housing that can fit a number of different weapons that are all controlled by a tank in the same way. Most importantly, is the emphasis on safety. During combat, the weapon systems cannot become unreliable or fail lest the pilots be put in...
PLEASE READ ALL OF THESE INSTRUCTIONS BEFORE BEGINNING THIS ASSIGNMENT. For this assignment, you need to...
PLEASE READ ALL OF THESE INSTRUCTIONS BEFORE BEGINNING THIS ASSIGNMENT. For this assignment, you need to analyze the information below from BOTH the management AND the employee perspective. This information pertains to a labor union in a simulated/made up/not real firm in Glen Ellyn. The first part of your information relates to Management – the second part relates to the Labor Union employees. I have provided you with information from the last union negotiations at the plant in 2016. It...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT