1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yKpoI14uk [10]
4 years ago
13

Create a class, using separate files, named DynamicGrades. (2 points) This class has three data members: an int that represents

the student id, an int that stores the number of grades, and a pointer to int that represents a dynamic array the size specified by the previous data member. (2 points) Create at least one constructor that allocates the appropriate dynamic array. Also create a destructor to free the dynamic array. (2 points) Create at a mutator function that takes three parameters: an int that represents the id of the student, an int that represents the index location for the grade, an int that represents the grade for the location specified. (2 points) Create an accessor function that takes two parameters: an int that represents the id of the student, and int that represents th index location for the grade. The function returns the grade for the location specified. (1 point) In main() , create a regular object and a dynamic object. Exercise all constructors and functions. Provide all source code, each file containing a comment with your name, course code and date. Also provide a screenshot with a sample run (1 point). Submit source code and screenshot together in a zip file.
Computers and Technology
1 answer:
Alex4 years ago
3 0

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

//DynamicGrades.h

class DynamicGrades

{

public:

DynamicGrades(int size);

~DynamicGrades();

void mutate(int studentId, int index, int grade);

int getGrade(int studentId, int index);

private:

int m_studentId;

int m_noofGrades;

int* m_dynamicArr;

};

//DynamicGrades.cpp

#include "DynamicGrades.h"

DynamicGrades::DynamicGrades(int size)

{

m_noofGrades = size;

m_dynamicArr = new int[m_noofGrades] {0};

}

DynamicGrades::~DynamicGrades()

{

if(nullptr != m_dynamicArr)

delete[] m_dynamicArr;

}

void DynamicGrades::mutate(int studentId, int index, int grade)

{

m_studentId = studentId;

if (index < m_noofGrades)

m_dynamicArr[index] = grade;

}

int DynamicGrades::getGrade(int studentId, int index)

{

if (index >= m_noofGrades)

return -1;

return m_dynamicArr[index];

}

//Main.cpp

#include "DynamicGrades.h"

int main()

{

DynamicGrades* grade = new DynamicGrades(5);

DynamicGrades grade2(10);

for (int i = 0;i < 5;++i)

{

grade->mutate(2, i, i + 1);

}

for (int i = 0; i < 10; i++)

{

grade2.mutate(3, i, i + 1);

}

cout << "Grades are " << endl;

for (int i = 0;i < 5;++i)

{

cout << grade->getGrade(2, i) <<" ";

}

cout << endl;

for (int i = 0; i < 10; i++)

{

cout << grade2.getGrade(3, i) << " ";

}

}

You might be interested in
How many functions can Excel perform?
Vlad [161]

Answer:

G

Explanation:

because

3 0
4 years ago
Atomic Term If an atom carries no charge, the positive charges from protons are balanced by the negative charges from the
Neko [114]

Answer:

yee ha

Explanation:

7 0
4 years ago
You have just connected a new computer to your network. The network user static IP addressing. You find that the computer can co
choli [55]

Answer:

Default gateway

Explanation:

The default gateway would be needed to change for the configuration value because when plugged to the computer system into other's network. The Internet Protocol addressing for network users that is static. Then, the other user finds the system can connect on a similar subnet with hosts and not with hosts on another subnet and no further computer systems have facing the problem.

3 0
4 years ago
Read 2 more answers
The computers in the administrative offices of the four schools throughout the district are networked to enable employees to acc
muminat
These computers in administrative offices or schools throughout the district that are networked to each other has the type of network most likely used by the workers is LAN network. Usually LAN networks are used in small offices or rooms.
3 0
4 years ago
" Which technique for representing numeric data uses the mantissa to hold the significant digits of a value?"
UkoKoshka [18]

Answer:

signed magnitude

Explanation:

A numeric value that is approximate consists of a mantissa and an exponent. The mantissa is a signed numeric value, so also is the exponent a signed integer that specifies the magnitude of the mantissa.

4 0
4 years ago
Other questions:
  • The ____ keyword specifies that a function or method does not return a value.
    5·1 answer
  • Programmers use a(n) ____ when they need the computer to repeatedly process one or more program instructions until some conditio
    13·1 answer
  • Someone please help me with the right answer please
    13·1 answer
  • . Write a code to define a linked list node using the above defined structure student (i.e. the data of the node is a student st
    11·1 answer
  • Which of the following tasks is least effective at preventing a computer virus?
    7·1 answer
  • The replacer parameter of the stringify method accepts a/an ______________ or an array.
    15·1 answer
  • You are developing open-source software based on existing source code developed by someone else. What is the term for the piece
    9·1 answer
  • Explain the working principle of computer? can anyone tell​
    14·1 answer
  • Which would you use to get the number of elements in a dictionary?
    6·1 answer
  • What is a thread? what resources does it share with other threads in the same process?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!