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 an attacker presents a program or himself as someone else to obtain private information and pretends to be a legitimate web
timofeeve [1]
A spoofing attack. "<span>a situation in which one person or program successfully masquerades as another by falsifying data, thereby gaining an illegitimate advantage."</span>
8 0
3 years ago
Where can students quickly locate a list of current classes?
Olenka [21]
In the front office or if your school has student vue it would be on the first page if online school just scroll down to classes
4 0
3 years ago
At the second simple query wizard dialog box, you are asked whether you would like to create a detail or a(n) _____ query.
Alisiya [41]
The correct answer is: Summary

<span>If you only selected fields from a single table in the first screen, then when you click the “Next >” button to continue, you will only need to provide the query with a name and then click the “Finish” button to finish creating the query. If, however, you picked data fields from two or more related tables, then when you click the “Next >” button, you will instead view a second screen which asks if you would like a “Detail” or “Summary” query. You can select the option button for the type of query that you wish to create. If you select “Summary,” then you will be able to click the “Summary Options…” button to open the “Summary Options” dialog box. In this dialog box, you can select what type of summary to perform over a selected field. Make your selections, and then click the “OK” button to return to the “Simple Query Wizard.”</span>

Select summary to show only results of aggregate functions.

Select the aggregate function and the field name of the numeric field in the list box. You can enter as many aggregate functions as you want, one in each row of controls.

Aggregate function

Select the aggregate function.

Field name

Select the numeric field name.

+

Appends a new row of controls.

-

Removes the last row of controls.

3 0
3 years ago
Which of these agencies main goal is the promotion of consumer protection?Immersive Reader
sattari [20]

Answer:

FTC (Federal Trade Commission)

Explanation:

However, it is not just the one government body that works to ensure consumer protection. The FTC is certainly one, however, though the others are the Food and Drug Administration, Financial Protection Bureau and the US Department of Justice. And all these bodies together ensure that the rights of the consumer are protected, through enforcement of various acts, and each of them deals with a certain type of good.

6 0
3 years ago
Why was the 80s bad for Disney i know one example but ill tell you after you answer
Bond [772]

Answer:

The dark stories behind it? i dont  know lol

5 0
3 years ago
Other questions:
  • Which type of movement lets the player control an object's movement?
    5·1 answer
  • Given an array temps of double s, containing temperature data, compute the average temperature. Store the average in a variable
    14·1 answer
  • Which of the following is a way the operating system prevents unknown or unauthorized users from accessing the system?
    15·2 answers
  • ________ are used in input, processing, and output operations that can help create more efficient programs as the data can be pr
    11·1 answer
  • When you send an email how many computers does it go to
    12·1 answer
  • 2 The software needed to send an email is:
    7·1 answer
  • Among object-oriented languages, one feature that varies considerably is whether the language allows multiple inheritance. C++ d
    5·1 answer
  • Any device that uses light to read and write information.
    9·1 answer
  • _______ is identical to the conventional typewriter keyboard
    8·2 answers
  • How does links helped a student like you in navigating the different available websites?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!