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
which tool in administrative tools should you open if you want to view messages to troubleshoot errors? a. resource monitor b. e
VikaD [51]

A tool in administrative tools which you should open if you want to view messages to troubleshoot errors is an: b. event viewer.

<h3>What is an operating system?</h3>

An operating system (OS) can be defined as a system software that's usually pre-installed on a computing device by the manufacturers, so as to manage random access memory (RAM), software programs, computer hardware and all user processes.

<h3>What is an event viewer?</h3>

An event viewer can be defined as an administrative tool that is found in all versions of Windows Operating System (OS) which is designed and developed to enable administrators and end users in viewing the event logs of software application and system messages such as errors on a local or remote machine.

In this context, we can reasonably infer and logically deduce that an event viewer is a tool in administrative tools which you should open if you want to view messages to troubleshoot errors.

Read more on event viewer here: brainly.com/question/14166392

#SPJ1

4 0
1 year ago
Is jesus dead or alive
Morgarella [4.7K]

Answer:

Explanation:

i think he alive but in heaven i dunno

8 0
2 years ago
You should check your battery ___________. Every week Never Every six months Every 30,00 miles
vova2212 [387]

The answer is Every six months

A battery acts as the brain of a car and is used to power almost everything. It can last up to five years. However, this lifespan will depend on how well the battery is maintained and the type of weather conditions you live in. Aim to check your car battery at least twice a year. Actually, it is best to check your battery regularly and not to wait for your mechanic to test your battery during routine servicing.

5 0
3 years ago
Read 2 more answers
A(n) _____ evaluates a specified data set and returns certain fields from that data set as instructed.
elena55 [62]

The correct answer is Query

5 0
3 years ago
Read 2 more answers
A Java main method uses the parameter (String[ ] variable) so that a user can run the program and supply "command-line" paramete
Firdavs [7]

Answer:

The answer is "Option a"

Explanation:

  • In java, the main function is the point of entry of every java program. Its syntax always starts "public static void main" with (String args[]), in which it can also be modified by the name of the string array name.
  • It also known as an entry point is the key process. In any program, it is the first method, that executes whenever you run a program. There is one main feature in a regular app that uses instances of certain classes to operate.
4 0
2 years ago
Other questions:
  • A motherboard uses dual channeling, but you have four DIMMs available that differ in size. The motherboard supports all four siz
    7·1 answer
  • What are the two main things an operating system does?
    14·1 answer
  • What is the use of ROM chip in computer system?​
    13·1 answer
  • What is the primary reason that organizations change their structure through downsizing, outsourcing, and offshoring as a means
    14·1 answer
  • Your job is to choose a data structure to implement polynomials whose coefficients are positive integers, such as 17x^4+4x^3+0x^
    9·1 answer
  • A rectangle indicates a single process.true or false​
    7·2 answers
  • Solve this for brainlest​
    10·1 answer
  • What makes you normally visit the site-graphics, layout, or content? Why?​
    8·2 answers
  • How does polymorphism enable you to program "in the general" rather than "in the specific"? Discuss the key advantages of progra
    11·1 answer
  • You are a software engineer at a company where management routinely encourages you and your colleagues to use pirated software.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!