answer.
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
Softa [21]
2 years ago
6

Write a full class definition for a class named Averager, and containing the following members:______An data member named sum of

type integer.An data member named count of type integer.A constructor with no parameters. Theconstructor initializes the data members sum and the data member count to 0.A function named getSum that accepts noparameters and returns an integer. getSumreturns the value of sum.A function named add that accepts an integer parameter and returns no value. add increases the value of sum by the value of theparameter, and increments the value of countby one.A function named getCount that accepts noparameters and returns an integer. getCountreturns the value of the count data member, that is, the number of values added to sum.A function named getAverage that accepts noparameters and returns a double. getAveragereturns the average of the values added to sum. The value returned should be a value of type double (and therefore you must cast the data members to double prior to performing the division).
Computers and Technology
2 answers:
alina1380 [7]2 years ago
6 0

Answer:

  1. public class Averager {
  2.    private int sum;
  3.    private int count;
  4.    public Averager(int sum, int count) {
  5.        this.sum = 0;
  6.        this.count = 0;
  7.    }
  8.    public int getSum(){
  9.        return sum;
  10.    }
  11.    public void add( int num){
  12.        this.sum+=num;
  13.        this.count++;
  14.    }
  15.    public int getCount(){
  16.        return this.count;
  17.    }
  18.    public double getAverage(){
  19.        double ave = (int)this.sum/this.count;
  20.        return  ave;
  21.    }
  22. }

Explanation:

  • Lines 1-3 contains the class declaration and the member (data fields)
  • Lines 4-7 is the constructor that initializes the fields to 0
  • Lines 8-10 is the method that returns the value of sum getSum()
  • lines 11-14 iss the method add() that adds a number to the member field sum and increases count by 1
  • lines 15 - 17 is the method that returns total count getCount()
  • Lines 18-21 is the method getAverage() That computes the average and returns a double representing the average values

balandron [24]2 years ago
3 0

Answer:

#ifndef AVERAGER

#define AVERAGER

class Averager{

public:

int sum;

int count;

Averager(){

sum = 0;

count = 0;

}

int getSum(){

return sum;

}

void add(int n){

sum += n;

count++;

}

int getCount(){

return count;

}

double getAverage(){

return (double)sum/count;

}

};

#endif

Explanation:

You might be interested in
The video clip on driverless cars explained that brain signals from the individual wearing the headset are converted by computer
Olegator [25]
A saftey issue because what is the car malfunctions or red light or police jus drive yo own car
5 0
2 years ago
Read 2 more answers
You’re trying to cast a video presentation from your tablet to a projector for a training session with some new hires. Although
Vikki [24]

Answer:

Troubleshooting steps to take:

  1. Restart the tablet
  2. Restart the projector

Explanation:

When such problems occur, the basic and quick troubleshooting step is to restart the device or devices involved.

  1. Restart the tablet: This could come in handy regarding this problem. The inability to connect to the projector could be due to the inability of a specific service or driver needed for the projector. Restarting the tablet will load up the drivers and services again to enable smooth connections. When a restart is done, bugs are fixed, internet connection is rectified, memory leaks are stopped, performance is aided, the RAM (Random Access Memory) is flushed or cleaned. This should resolve the problem, however, if not, try number 2.
  2. Restart the projector: There are driver software on projectors, and due to one system failure or another, these software may fail to load. This could affect its connection to another device. As done in (1), restarting the projector will fix those bugs and load up, which should solve the connection issue.
7 0
2 years ago
Find true or false. A hacker is hacking software with access in sensitive information from your computer​
Alina [70]
ITS TRUE!!I SEARCHED IT
7 0
1 year ago
Write a function named printtriangle that receives a parameter that holds a non-negative integer value and prints a triangle of
NemiM [27]
Static void PrintTriangle(int n){    for(;n>0;n--) {                Console.WriteLine(new String('*', n));    }}
5 0
2 years ago
You learned that properly edited resumes are necessary for making a good impression on a university or a potential employer. Dis
Daniel [21]

Answer:

it will not be a good impression and it will be hard to look for a job

Explanation:

3 0
2 years ago
Other questions:
  • Exercise 6.3 consider memory storage of a 32-bit word stored at memory word 42 in a byte-addressable memory. (a) what is the byt
    14·1 answer
  • Jimmy is preparing a slide show to teach the grade three students the importance of cleanliness. which element should he use in
    5·2 answers
  • Zoey has brought her computer in for servicing. When she dropped off her computer, she mentioned that her computer will sometime
    15·2 answers
  • The main problem with radio transmission is which of the following? Select one: a. Radio waves cannot travel through walls. b. W
    9·2 answers
  • Why can't you use Friedman's attack on block ciphers?
    12·1 answer
  • When employees have multiple concurrent connections, what might be happening to the VPN system?
    7·1 answer
  • The function below takes two arguments, a dictionary called dog_dictionary and a list of dog names (strings) adopted_dog_names.
    8·1 answer
  • rite a method so that the main() code below can be replaced by simpler code that calls method calcMilesTraveled(). Original main
    7·1 answer
  • Which OS function does a CLI fulfill? A User interface B Running applications C Hardware interface D Booting
    8·1 answer
  • Explain the emerging trends in microcomputer technology in relation to size​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!