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
Which of the following algorithmic efficiencies would be considered LEAST efficient?
LenaWriter [7]

Answer:exponential

Explanation: I believe

8 0
3 years ago
Which of the following are true about assembly language instructions and directives?
tia_tia [17]

Answer:

b. an instruction is executed at runtime.

Explanation:

In assembly language, an instruction typically dictates what task to be performed or executed by the processor and this happens at run time.

Closely related to an instruction is a directive which is a special type of instruction that tells the assembler how to perform a particular task and this happens at assembler time.

Instructions dictate what and directives dictate how.

Instructions typically generate machine codes while directives don't.

Examples of instructions are;

i.  AND for logical AND

ii. OR for logical OR

Examples of directives are;

i. ORG for origin

ii. EQU for equate

Therefore the only correct option is b. an instruction is executed at runtime.

3 0
3 years ago
If using the md5 hashing algorithm, what is the length to which each message is padded?
krek1111 [17]
If using the MD5 hashing algorithm, the length to which each message is padded 512 bits.

Answer: (d.) 512 bits.

MD5 stands for Message Digest 5. It is a hashing algorithm that is case sensitive.  It is a cryptographic hash values.

4 0
4 years ago
______ a word object in an Excel worksheet to activate the word features
Rudik [331]

I’d say (C): Double clicking.

Double clicking a word object in an Excel worksheet activate the word features. You are able to embed a word document or a word object in your Excel sheet and access it with a few clicks.You can edit Word features by double-clicking it





3 0
3 years ago
How to make windows hp laptop run faster speed​
almond37 [142]
Upgrade your shi-Tee WiFi
3 0
3 years ago
Other questions:
  • Question / UJU
    11·1 answer
  • May someone help please. :(
    9·1 answer
  • What is C.R.A.T systems used for?
    9·1 answer
  • Developers and organizations all around the world leverage ______ extensively.
    9·2 answers
  • Write a program to help a travelling sales person keep up with their daily mileage driven for business. In your main method, the
    12·1 answer
  • javascript Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment
    7·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    15·1 answer
  • Identify the symbol. please help!!<br>​
    7·2 answers
  • Define print_shape() to print the below shape. Example output:
    8·1 answer
  • All mortgage companies are willing to loan anyone money regardless of credit scores. True or false?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!