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
Write a method that takes a RegularPolygon as a parameter, sets its number of sides to a random integer between 10 and 20 inclus
monitta

Answer:

public static void randomize(RegularPolygon r){

   int side = (int)((20-10) * Math.random()) + 10;

   int length = (int)((12-5)  * Math.random()) + 5;

   // assuming the regularpolygon class has setSide and setLength methods.

   r.set.Side(side);

   r.setLength(length);

}

Explanation:

The randomize method is used to access and change the state of the RegularPolygon class attributes sides and length. The method accepts the class as an argument and assigns a random number of sides and length to the polygon object.

8 0
2 years ago
in ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).
damaskus [11]

In <u>looping</u> structures, the computer repeats particular statements for a certain number of times based on some condition(s).

<h3>What is a looping structure?</h3>

A looping structure can be defined as a type of function which instructs a computer to repeat specific statements for a certain number of times based on some condition(s).

This ultimately implies that, a computer repeats particular statements for a certain number of times based on some condition(s) in looping structures.

Read more on loop here: brainly.com/question/26130037

#SPJ11

4 0
2 years ago
Read 2 more answers
What does it mean when your check engine light comes on?
Ludmilka [50]
This website has an article about the on-board diagnostics system (OBD system) which turns on the Check Engine light in a motorized vehicle: https://motorist.org/articles/check-engine-light

Hope it helps you!
5 0
3 years ago
Select all that apply.
professor190 [17]
Social worker and legal aid worker

4 0
3 years ago
Read 2 more answers
what term defines inventiveness uncertainty and futuristic ideas typically deals with science and technology
Kruka [31]

Answer:

Innovation.

Explanation:

Innovation can be considered the ideal term, because an innovative idea arises from the set of a new technique, method or invention that aims to improve an existing method, standard, or product.

However, added to an innovative idea is the risk, since innovation breaks an already established standard, so it is through science and technology that an invention will gain greater foundation and recognition, which increases its credibility and acceptance.

3 0
3 years ago
Other questions:
  • A Color class has a method getColorName that returns a string corresponding to the common name for the color, e.g., yellow, blue
    11·1 answer
  • What will be the output of “AAAAMMMMMHHHVV” using a file compression technique?
    9·2 answers
  • Help asap. 10 points.
    8·2 answers
  • . Dеclarе a onе-dimеnsional array of 30 doublеs (on thе stack) namеd rainfall
    11·1 answer
  • ____________________ is the premeditated, politically motivated attacks against information, computer systems, computer programs
    6·2 answers
  • Given the following sets, for each set operation provide the elements of the resulting set in set notation or using a well-known
    5·1 answer
  • List the difference between GIGO and bug ​
    15·1 answer
  • What is the remainder obtained by dividing x 7 + x 5 + 1 by the generator polynomial x 3 + 1?
    9·1 answer
  • please help me to do this computer homework I beg you all please help me to get the answers please its important please ​
    12·1 answer
  • I need to send this in ASAP
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!