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
Intellectual property rights are exclusive rights that help protect both the created and the creation. IPR offers exclusively wh
dedylja [7]
IPR offers ownership of the intellectual property. The owner of the property has the right to a monetary gain from those who wish to use it.
8 0
2 years ago
Read 2 more answers
Why are wiki's not secure​
Nookie1986 [14]
Wikipedia is not a reliable source for citations elsewhere on Wikipedia. Because, as a user-generated source, it can be edited by anyone at any time, any information it contains at a particular time could be vandalism
7 0
2 years ago
What are the steps for inserting an internal link?
julia-pushkina [17]

Answer:

=

Worksheet

Ctrl + Enter

Explanation:

4 0
2 years ago
Read 2 more answers
Assume the following variable definition appears in a program:
AnnZ [28]

Answer:

cout << setprecision(2)<< fixed << number;

Explanation:

The above statement returns 12.35 as output

Though, the statement can be split to multiple statements; but the question requires the use of a cout statement.

The statement starts by setting precision to 2 using setprecision(2)

This is immediately followed by the fixed manipulator;

The essence of the fixed manipulator is to ensure that the number returns 2 digits after the decimal point;

Using only setprecision(2) in the cout statement will on return the 2 digits (12) before the decimal point.

The fixed manipulator is then followed by the variable to be printed.

See code snippet below

<em>#include <iostream>  </em>

<em>#include <iomanip> </em>

<em>using namespace std;  </em>

<em>int main()  </em>

<em>{  </em>

<em> // Initializing the double value</em>

<em> double number = 12.3456;  </em>

<em> //Print  result</em>

<em> cout << setprecision(2)<< fixed << number;  </em>

<em> return 0;  </em>

<em>}  </em>

<em />

4 0
3 years ago
You've just installed a new video card in a user's Windows workstation. When the system is powered on the screen is blank. You
valentinak56 [21]

After having verified that the video cable is installed correctly we should check to see that the computer's RAM is correctly fastened to the motherboard and functional.

The question states that the video card being installed is new, therefore we can comfortably assume that the card itself is not the issue. Other computer components that can cause a blank screen immediately upon powering on the workstation are:

  • RAM
  • Hard drive
  • Bad video driver.
  • Monitor input is faulty

however, assuming the installation was performed correctly, it is not likely to be caused by a bad video driver and a faulty monitor input is very improbable given that there are very few ways this can break to begin with.

A bad or missing hard drive may cause this kind of issue because the workstation will not have a windows file to boot. In most cases, this will not cause a completely blank screen without first allowing access to the BIOS.

After having verified that the video cable is installed correctly, the very next thing you should check is if the RAM is installed correctly. This is because the issue explained is exactly what will happen if a workstation attempts to boot without RAM, and also because it is the easiest fix among the possible causes and any troubleshooting should always be performed in order from the easiest fix to the most difficult.

To learn more visit:

brainly.com/question/2160588?referrer=searchResults

8 0
2 years ago
Other questions:
  • What is the name for the individual sections of the ribbon in PowerPoint 20162
    8·1 answer
  • Which statement best describes a scientific theory?
    13·1 answer
  • Susan has always wanted to be a veterinarian. When doing her research, she answers all self-assessments geared toward that caree
    13·1 answer
  • Write a function swap that swaps the first and last elements of a list argument. Sample output with input: 'all,good,things,must
    10·2 answers
  • Suppose a MATV/SMATV (Satellite Master Antenna Television) firm has to start it's operation in the metropolitan area of a countr
    12·1 answer
  • What command displays detail information about the OSPF interfaces, including the authentication method?
    7·2 answers
  • Which of the following statements are true regarding models? Select 3 options.
    11·1 answer
  • When is 1600 plus 25 and 1700 minus 35 the same thing?​
    10·1 answer
  • Your task is to implement a function replace_once(t, d), that takes a text t and a replacement dictionary d, and returns the res
    10·1 answer
  • A computer program that enables users to create and work with files and folders is called what?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!