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
Which of the following is something all models use to determine relationships?
Aleks [24]

Answer:

Math

Explanation:

Which of the following is something all models use to determine relationships?

The answer would be math.

8 0
4 years ago
What is the meaning of Ram?​
masya89 [10]

Answer:

Random-Access Memory

Explanation:

used as a short-term memory for computers to place its data for easy access

5 0
2 years ago
A database planner names a field “Organic ingredients_3”. Why would this name Create possible problems in programming?
o-na [289]

Answer:

I think the answer is 2.

hope it will help you

4 0
3 years ago
Read 2 more answers
Assume that x and y are boolean variables and have been properly initialized. !(x || y) || (x || y) The result of evaluating the
LenaWriter [7]

Answer:

The answer is "Always true "

Explanation:

Following are the program to this question:

#include <iostream>//header file

using namespace std;

int main()//main method

{

bool x=true;//defining bool variable x and assign value

bool y=false;//defining bool variable y and assign value

if(!(x || y) || (x || y))//use given condition with if block

{

   cout<<"True";//print true message

}

else//defining else block

{

   cout<<"false";//print false message

}

   return 0;

}

In the above code two bool variable is declared, that hold ture and false, and used in the given expression with the condition statement, that checks the given value. In the code the logical gate OR gate that always print the true value.

3 0
3 years ago
__________________ is a technique can be beneficial when driving next to parked vehicles or approaching signal lights or interse
NISA [10]

Answer:

Covering the brakeis a technique can be beneficial when driving next to parked vehicles or approaching signal lights or intersections

7 0
3 years ago
Other questions:
  • Kwan is using JavaScript extensively to add interactivity to his Web site. Contained within his script is a counter object that
    8·1 answer
  • If the polar bear were taken out of the food chain what would happen to the seal population
    10·1 answer
  • Keep the base of your _________ on the mouse pad or desk?
    12·2 answers
  • The Classic Triangle Testing Problem, (Myer's Triangle): A program reads three integer values. The three values are interpreted
    10·1 answer
  • In a stream channel what is deposited first?
    7·1 answer
  • One of the prominent movies released in the 1950s is
    15·2 answers
  • 3. In a 32-bit CPU, the largest integer that we can store is 2147483647. Verify this with a
    12·1 answer
  • The script in the dynamic data section of the Web page template will check the value of the ____ array if the get method is used
    8·1 answer
  • Abdul wants to create a header for a webpage and enters this line: Welcome to Abdul’s webpage! , but the title is smaller than w
    12·1 answer
  • Who do we need more in the world? Computer technicians, or electric technicians and why.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!