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]
4 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]4 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
To indent the first line of a paragraph which key should you use
JulijaS [17]
You need to press the spacebar
3 0
4 years ago
Read 2 more answers
Consider the information about the meaning of the word analog from paragraph 2 listed below. Which of the following phrases best
Reika [66]

Answer:

drzvkhy67re4d

Explanation:

Preciate u

3 0
3 years ago
When your tire blows out in the middle of a drive, you should _____. A. let go of the steering wheel B. pump the brakes immediat
notsponge [240]
The answer is D. Because you are in the middle of the road so put your caution lights on and steer to the side of the road
3 0
4 years ago
Read 2 more answers
____ is another term for document properties.
MArishka [77]
Metadata is the other term for document properties. It is a data that describes another data. The word “meta” means “an underlying definition or description”. Traditionally, it was used in libraries as card catalogs. In digitals, metadata is also used to describe digital data. 
3 0
3 years ago
In the context of this passage, which of the following is a synonym for alleged? A intended B claimed C denied D revealed
Zinaida [17]
B. Claimed

Alleged means somebody CLAIMED that you did something. So, you're being accused of doing something that you may have not done. I hope this helps! :)
7 0
3 years ago
Other questions:
  • What was the second phone made in the world called?
    5·1 answer
  • A database administrator (DBA) must have a clear understanding of the fundamental business of an organization, be proficient in
    11·1 answer
  • What kind of battery does a dji spark have?
    12·1 answer
  • BRAINLIEST !!A game design document is like a diary for game developers.
    11·1 answer
  • A problem associated with old drivers is:
    8·1 answer
  • What is one reason that writing effective messages is so important
    11·2 answers
  • How do computers benefit individuals' health care?
    10·1 answer
  • All the read/write heads a hard disk are controlled by a(n) ____ which moves the read/write heads across the disk surfaces in un
    13·1 answer
  • Sonja is writing a program to compare two numbers and print the larger number. Which of these should be used?
    6·1 answer
  • Who was the first person to develop http the language in which servers and browsers communicate
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!