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
Paladinen [302]
3 years ago
14

Write a class named Accumulator containing: An instance variable named sum of type integer. A constructor that accepts an intege

r parameter, whose value is used to initialize the sum instance variable. A method named getSum that returns the value of sum. A method named add that accepts an integer parameter. The value of sum is increased by the value of the parameter.
Computers and Technology
1 answer:
Genrish500 [490]3 years ago
4 0

Answer:

The following are the code in the C++ Programming Language.

//define header file

#include <iostream>

// using namespace

using namespace std;

//define a class

class Accumulator

{

//set private access modifier

private:  

//declare integer type variable

int sum;

//set public access modifier

public:

//define constructor  

Accumulator (int sum)

{

//refer the same class as instance variable

this->sum = sum;

}

//define integer type function

int getSum()

{

//return the value of sum

return sum;

}

//define void type function

void add (int value)

{

//variable sum is increased by the argument value

sum += value;

}

};

Explanation:

<u>The following are the description of the code</u>.

  • Firstly, set the required header file and namespace then, define a class 'Accumulator' and inside the class.
  • Set private access modifier then, declare an integer data type variable 'sum'.
  • Declare a class constructor whose name is the same as the class name 'Accumulator()' and pass integer data type argument 'sum' in its parameter that refers to the same class as instance variable.
  • Define a integer data type function 'getSum()' that return the value of the variable sum.
  • Finally, define a void type function 'add()' and pass the integer data type argument 'value' in its parameter in which the variable sum is increased by the argument value .
You might be interested in
When disabling inherited permissions on an object, what happens if you select Remove all inherited permissions from this object?
Rasek [7]

Answer:

Answer explained below

Explanation:

When disabling inherited permissions on an object, if you select Remove all inherited permissions from this object then you lose every user or group assigned to the folder.

This will delete all existing permissions, including administrator accounts, leaving you a blank slate to apply your own permissions to the folder.

5 0
3 years ago
You are researching RAM for a computer you are building for a friend who will be using the system as a home office server for he
pashok25 [27]

Answer:

ECC RAM

Explanation:

ECC RAM is the most popular Random Access Memory out there that is used by most business servers. Dealing with big data for most huge businesses is crucial. The need to prevent loss of data requires that they purchase ECC RAM. ECC RAM automatically protects the systems from potential errors that occur in memory. Any abrupt changes in temporary data stored in ECC RAM are automatically corrected. This is achieved by an additional memory chip that acts as error detection for the other eight RAM chips.

8 0
3 years ago
Laura is confused with the spelling of the word pronunciation. She types the word as pronounciation throughout a document. Which
Ivan

Not really is she wants the words that she's typing down sometimes it's not necessary to leave it to the auto correct It can always be bad when re-reading it again.

5 0
2 years ago
If you delete selected cells using the Delete key on your keyboard, only the _______ of the cells is removed. formatting content
kap26 [50]
If you delete selected cells using the Delete key on your keyboard, only the _______ of the cells is removed.
Content
8 0
3 years ago
Read 2 more answers
I had about 83 GB before I installed Xcode, I was in the middle of the installation and reconsidered my decision but it's still
Natasha_Volkova [10]

You can try downloading some kind of computer cleaner like CleanMyMac X free version, also definitely restart your computer if you haven't done so already.

4 0
2 years ago
Read 2 more answers
Other questions:
  • Write a Tip Calculator in code in VMware Fusion
    13·1 answer
  • Easy question how the internet has impacted y’all life
    13·1 answer
  • Which amendment discussed in the unit do you think has the greatest effect on your life? Why?
    14·1 answer
  • Name some of the file extensions for images and provide more information about one or two of them.
    12·1 answer
  • Plz help ASAP
    10·1 answer
  • What is the difference between a software engineer and a system analyst?
    8·1 answer
  • In French class, Blue puts on a visor and the environment changes to that of a café in Paris. Which of the following terms descr
    12·2 answers
  • Tgif
    7·1 answer
  • ) Printers today have many features that include improved quality, photo printing capabilities, digital camera connectivity, bui
    11·1 answer
  • Choose the answer.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!