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]
3 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:
Alex3 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
Which statement describes borders and shading ?
Marina CMI [18]

Answer: Borders are rules you can add to any or all of the four sides of a paragraph. Shading is the color or artistic design you use as background for a paragraph. Borders and shading are formatting tools for enhancing text, paragraphs, table cells or frames.

3 0
2 years ago
You are looking at computer ads. One has a processor that is 3.64GHz. What does this mean?
aliina [53]

Answer:

The higher the clockspeed the more the cpu can do

Explanation:

8 0
2 years ago
An organization requires secure configuration baselines for all platforms and technologies that are used. If any system cannot c
Romashka [77]

Answer:

C. Process a risk acceptance for 2633 and remediate 3124.

Explanation:

There are various business risks. Some are inherited risks while other are risks are associated with nature of business. It is dependent on business owners that they want to accept risk or mitigate the risk. Risk acceptance is based on the strategy of the management. In the given scenario Accounting Prod Production has low risk 2633 which is accepted while 3124 is high risk which is remediated.

8 0
2 years ago
A student who used a regression model that included indicator variables was upset when receiving only the following output on th
jeka57 [31]

Answer:

This is a multicolinearity problem and the student should determine the variable(s) that cause(s) the problem and remove it.

Explanation:

This information means that there exists a linear combination between the independent variables. The problem might have developed due to multicolinearity producing almost perfectly linearly dependent columns.

This could also be as a results of single matrix created when the student use an incorrect indicator variables and included an additional indicator column which created linearly dependent columns.

4 0
3 years ago
_____ involves those activities that ensure the orderly dissolution of a system, including disposing of all equipment in an envi
Ad libitum [116K]

Answer:

The answer is  a stage of system development that involves...

Explanation:

___a stage of system development_ involves those activities that ensure the orderly dissolution of a system, including disposing of all equipment in an environmentally friendly manner, closing out contracts, and safely migrating information from the system to another system or archiving it in accordance with applicable records management policies.

That is the definition of system disposal

5 0
2 years ago
Other questions:
  • Malware that corrupts the target operating system in such a manner that a network defender can no longer trust the native OS is
    15·1 answer
  • A5.3 1012 kg satellite is 1,800 m from another satellite that has a mass of 3.5 x 108 kg. What is the gravitational
    6·1 answer
  • Micheal has increased the contrast of the given picture. Which feature or menu option of a word processing program did he use? A
    15·1 answer
  • Write a program that deliberately contains an endless or infinite while loop. The loop should generate multiplication questions
    13·1 answer
  • A lottery ticket contains five unique numbers. A set of unique numbers does not contain repeated elements. The winning combinati
    10·1 answer
  • A student that earns a well qualified score on an ap exam would receive a ___
    13·1 answer
  • What is the purpose of a primary key?
    5·1 answer
  • Users who are connecting to an NLB cluster have been complaining that after using the site for a few minutes they are prompted t
    15·1 answer
  • Write a C function named apply_all that expects two arrays of integers and their sizes and dynamically allocates a new array of
    7·1 answer
  • After a Hacker has selects her target, performed reconnaissance on the potential target's network, and probed active Internet Ad
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!