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
What is the basic unit for storing data in exel
PtichkaEL [24]
A cell is the basic unit for storing data in exel
7 0
3 years ago
Lenders always accept applications for credit
LenKa [72]
The correct answer to the question that is being stated above is FALSE.

The statement is false because lenders do not always accept applications for credit. Lenders always consider credit history of the applicant. If the applicant has a good credit history background, then he qualifies.
3 0
3 years ago
PLS HELP MEE!!!
kramer

Answer:

starting with lowercase letters, using uppercase letters for the first letter in a new word

Explanation:

starting with a dollar sign, using lowercase for the remaining parts of each word

4 0
2 years ago
What tells the hardware what to do and how to do it?
oksano4ka [1.4K]

Answer:

I think its CPU

Explanation:

8 0
2 years ago
Describe the three functions of all programming languages and list at least two specific examples of each. The examples can be f
natta225 [31]

Answer:

The 3 functions of all programming languages are Input, Execution and collection.

They are described below:

Explanation:

1. <u>INPUT</u>: An input function can be defined as the function in programming that enables or allows the computer take in an input in form of any data type from the user. The input is either stored directly into a variable identifier or processed. A real-life scenario of an input function is taking in food. The intake of any substance into the mouth can be likened to an input function. We take in food into the body through the mouth and this is processed within the body.

Another example of input in a real-life scenario is dumping your trash into the bin. In this case, the bin is taking your trash bag as an input.  An input function in programming can take in integers, strings, character, float, arrays or any kind of data type. An input function allows the user send information to the computer using the keyboard, voice, gestures and other forms of communication.

  • <u>Examples of Input Function using C# programming language</u>

<em>Console.WriteLine("Please type any input from keyboard and press enter:");   </em>

<em>string userName = Console.ReadLine(); </em>

From the above example, In the first line of code, the compiler asks the user to input anything via the keyboard.

In the second line of code, the compiler takes in whatever the user has typed and stores it as a variable that we defined as userinput.<em> </em>

  • <u>Example of Input Function Using Python programming language</u>

<em>print('Type in your name:') </em>

<em>username = input() </em>

The first line of code requests that the user types in his name as an input, then Second line of code takes in the input and stores it as a variable declared as username

2. EXECUTION: execution in programming can be described as the process of performing some kind of operation as instructed by the code. This means that the computer reads through the code and performs any operation that it is asked to perform. such execution operation may include arithmetics, iteration, comparison and as many instructions as written in the code.

A real life scenario of execution is when you press the "play" button of an ipod. The ipod executes the "play" action and plays any song within in.

Another example is pressing 2+2 in your calculator and pressing "=" sign. The calculator performs the 2+2 operation and gives a result.

So we can then say that for every execution there is usually a result.  

  • <u>Examples of Execution Function using C# programming language</u>

<em>class ExecuteExample</em>

<em>  { </em>

<em>    static void Main(string[] args) </em>

<em>    { </em>

<em>      int additionop= 100 + 500; </em>

<em>     } </em>

<em>  }</em>

In the code above, execution occurs at the highlighted line. The compiler is asked to add the numbers 100 and 500. The act/process of adding both numbers is called EXECUTION.

  • <u>Example of Execution Function Using Python programming language</u>

<em>print('Type in your name:') </em>

<em>username = input() </em>

<em>print('We just executed, ' + username )</em>

Continuing from our code in the "input example" . As seen in the code above, execution occurs at the point where the computer prints the output of the user's input. In this case the computer prints "we just executed, + whatever value the user had passed as an input."

3. COLLECTION: Collection in programming is used to describe the process where a computer objects collects and groups  similar elements to form a single unit. This collection can be a group of similar data types.

A real life example of a collection is a Queue of people at an ATM. This can define the Queue collection type. usually this kind of collection is considered as a First in First out collection.

Another example of collection can be a List of cars in a Ford car garage. This garage takes in a range of cars that are Ford models only.

  • <u>Example of Collection Function using C# programming language</u>

List : A List is a type of collection as seen below:

<em>var listcollect = new List<string>(); </em>

<em>listcollect .Add("fordexplorer"); </em>

<em>listcollect .Add("fordedge"); </em>

<em>listcollect .Add("fordescape"); </em>

<em>listcollect .Add("fordtruck"); </em>

<em>foreach (var car in listcollect) </em>

<em>{ </em>

<em>    //do somethin</em>

<em>}</em>

The above code creates a collection(list) of the car names as a string in a tipper garage, adds elements(items) to this list and iterates through the list. This is a typical example of a collection.

  • <u>Example of Collection Function using C# programming language</u>

Queue: a queue is a case of colleciton that uses the first in first out idea. The first in first out concept is : first element to be taken in is pushed out first also known as FIFO:

<em>class ExmapleofQueue</em>

<em> { </em>

<em>  static void Main(string[] args) </em>

<em>  { </em>

<em>   Queue sampleQueue= new Queue(); </em>

<em>   sampleQueue.Enqueue(1); </em>

<em>   sampleQueue.Enqueue(2); </em>

<em>   sampleQueue.Enqueue(3); </em>

<em>   foreach (Object numberel in sampleQueue) </em>

<em>   { </em>

<em>    //do something</em>

<em>   }</em>

<em>}</em>

<em>}</em>

<em>From example above, we can see that we created a queue called sampleQueue. This holds a queue of integers.</em>

<em />

8 0
3 years ago
Read 2 more answers
Other questions:
  • Marie uses a browser to visit a blog. What is the unique identifier of the blog?
    5·1 answer
  • What component on a smartphone requires pairing with another device?
    8·1 answer
  • Why should you delete files from your computer? (multiple answers can be chosen)
    5·2 answers
  • Who was eqvtime tayaishvili?​
    13·2 answers
  • Perform the following conversions from decimal to binary, octal and hexadecimal systems. a) 1710 b) 132110C) 36010d).7510e).3906
    8·1 answer
  • A server, also called a(n) _______________, operating system is a multiuser operating system because it controls a central compu
    6·1 answer
  • A computer reads a sequence from top to bottom and left to right? True or False
    6·1 answer
  • Write a statement that increments numUsers if updateDirection is 1, otherwise decrements numUsers. Ex: if numUsers is 8 and upda
    11·1 answer
  • Which statement about the subject line is true? The subject line can be found just below the message box. The subject line is ma
    13·2 answers
  • Create a vector of structures experiments that stores information on subjects used in an experiment. Each struct has four fields
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!