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
What is used to give credit to the source from which information is obtained?
Sati [7]
The Answer is (A) because a citation gives credit to the sources from which your information was obtained. Linkage has nothing to do with it... Plagiarism is the exact opposite of that.... And a format is just a way something is in order or arranged.
8 0
3 years ago
In this lab, you create a programmer-defined class and then use it in a C++ program. The program should create two Rectangle obj
MakcuM [25]

The program based on the information given is illustrated below.

<h3>What is a program?</h3>

A computer program simply means a sequence of instructions in a programming language that is created for a computer to execute.

It should be noted that computer programs are among the component of software.

The program to create two rectangle objects and get their area and perimeter is depicted:

// Rectangle.cpp

using namespace std;

class Rectangle

{

public:

// Declare public methods here

void setLength(double);

void setWidth(double);

double getLength();

double getWidth();

double calculateArea();

double calculatePerimeter();

private:

// Create length and width here

double length, width;

};

void Rectangle::setLength(double len)

{

length = len;

}

void Rectangle::setWidth(double wid)

{

// write setWidth here

width = wid;

}

double Rectangle::getLength()

{

// write getLength here

return length;

}

double Rectangle::getWidth()

{

// write getWidth here

return width;

}

double Rectangle::calculateArea()

{

// write calculateArea here

return length*width;

}

double Rectangle::calculatePerimeter()

{

// write calculatePerimeter here

return 2*(length+width);

}

// This program uses the programmer-defined Rectangle class.

#include "Rectangle.cpp"

#include <iostream>

using namespace std;

int main()

{

Rectangle rectangle1;

Rectangle rectangle2;

rectangle1.setLength(10.0);

rectangle1.setWidth(5.0);

rectangle2.setLength(7.0);

rectangle2.setWidth(3.0);

cout << "Perimeter of rectangle1 is " << rectangle1.calculatePerimeter() << endl;

cout << "Area of rectangle1 is " << rectangle1.calculateArea() << endl;

cout << "Perimeter of rectangle2 is " << rectangle2.calculatePerimeter() << endl;

cout << "Area of rectangle2 is " << rectangle2.calculateArea() << endl;

return 0;

}

/*

output:

The perimeter of rectangle1 is 30

The area of rectangle1 is 50

The Perimeter of rectangle2 is 20

The area of rectangle2 is 21

*/

Learn more about program on:

brainly.com/question/1538272

#SPJ1

8 0
1 year ago
A thermogram taken outside a house shows high amounts of thermal energy around the windows but not around the roof. which conclu
mestny [16]

The conclusion sustains the thermogram will be that the windows are not energy efficient, but the roof stands energy efficient.

<h3>What is Thermography?</h3>

Thermography exists a noninvasive method that employs an infrared camera to develop pictures that depict patterns of heat and blood flow on or around the body's surface. A thermogram taken outside a house shows high quantities of thermal energy around the windows but not around the roof. The conclusion that supports the thermogram will be that the windows are not energy efficient, but the roof exists energy efficient.

Thermal energy (also named heat energy) is produced when a rise in temperature pushes atoms and molecules to move faster and collide with each other. The energy that reaches the temperature of the heated substance is named thermal energy. The term "thermal energy" exists utilized loosely in various contexts in physics and engineering. It can guide several different well-defined physical concepts.

To learn more about Thermography refer to:

brainly.com/question/1500896

#SPJ4

The complete question is,

A thermogram taken outside a house shows high amounts of thermal energy around the windows but not around the roof.

Which conclusion supports the thermogram?

The windows and the roof are energy efficient.

The windows and the roof are not energy efficient.

The windows are not energy efficient, but the roof is energy efficient.

The windows are energy efficient, but the roof is not energy efficient.

4 0
1 year ago
In a public switched telephone network, lines are terminated at the central office.
FrozenT [24]

Answer:

True.

Explanation:

A Central office or local office in Metropolitan cities is a building or an office where the phone lines coming from a home or office are terminated and connected to a bigger switching system.Central office got the switching equipment which holds the ability to switch calls long-distances or locally.Hence we conclude that the answer is True.

5 0
3 years ago
What is the binary equivalent of the volume 3F?
kaheart [24]

Answer:

The binary equivalent of the volume 3F is

A. 00111111

Hope it will help. :)❤

6 0
2 years ago
Other questions:
  • Which translator program reads small portions of a program at a time, translating them into machine instructions which are then
    12·1 answer
  • All the data points lie within UCL &amp; LCL and all of the data points are randomly distributed about the mean value central li
    7·1 answer
  • What is the legal right granted to all authors and artists that gives them sole ownership and use of their words, software, pict
    9·2 answers
  • What is a block cipher algorithm that operates on 64-bit blocks and can have a key length from 32 to 448 bits?
    8·1 answer
  • . Generate 106 message bits (random binary values (bool/int) ). 2. Generate the corresponding code bits for r = 3, 5. This means
    9·1 answer
  • You open a web page and log into your email. The traffic travels over many routers. What protocol will the routers use to determ
    6·1 answer
  • What is the name of the interface that uses graphics as compared to a command-driven interface?
    11·1 answer
  • The Mail Merge option is located in which tab? a;home b;insert c;refernces d;mailings
    11·2 answers
  • Similarities between inline css and internal css​
    6·1 answer
  • IN EXCEL, File, menu , edit, insert are all located in ?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!