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
United Broke Artists (UBA) is a broker for not-so-famous artists. UBA maintains a small database to track painters, paintings, a
lions [1.4K]

Answer:

Check the explanation

Explanation:

Kindly check the attached image below to see the relation and the table names.

7 0
3 years ago
Read 2 more answers
Using Word, Maureen is writing an outline of a presentation she plans to give to her company. She will be showing a video during
svlad2 [7]
A copy and paste would be fastest and easiest. As you can pinpoint the exact location to where you want the picture to be. 
5 0
3 years ago
Read 2 more answers
What are some text effects found in the WordArt gallery? Check all that apply.
Softa [21]
The answer is bevel, glow, reflection, shadow, and soft edges
3 0
4 years ago
Read 2 more answers
The protections from the security software must continue when the device is taken off the network, such as when it is off-grid,
snow_lady [41]

Answer:

third ighjojdudjz

ghddduewjj

wkckdjjj

Explanation:

cchmddkhwmx

ndhdnahdd

jruditndjed

3 0
3 years ago
How do you use OneDrive
Lerok [7]
I think it's to back up files
7 0
3 years ago
Other questions:
  • What might be the best response to a cyberbuly attack
    6·2 answers
  • onsider the following program: Peform a total of six exercises. Select one exercise from each of the following areas: hips and l
    6·1 answer
  • In a spreadsheet, there are many features that help you edit quickly. True False
    11·1 answer
  • Incident damage ____ is the rapid determination of the scope of the breach of the confidentiality, integrity, and availability o
    6·1 answer
  • A digital designer might do computer animation or video games true or false
    13·2 answers
  • The process of _____ determines what volume a system can handle by comparing its performance to standards in the industry? horiz
    14·2 answers
  • Type the correct answer in the box. Spell the word correctly. A company has its branches spread over five places in a state. It
    14·1 answer
  • Question 3 10 points Save Answer Many companies in the computer industry introduce new products and services frequently in an at
    7·1 answer
  • How can I hide my cracked phone screen? or How can I fix it myself without my parent finding out? or How can I fix my phone with
    14·1 answer
  • Which storage device is not recommended as a permanent storage solution?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!