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
Softa [21]
3 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]3 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]3 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
Write a program that reads in characters from standard input and outputs the number of times it sees an 'a' followed by the lett
Simora [160]

Answer:

Following is attached the code that works accordingly as required. It reads in characters from standard input and outputs the number of times it sees an 'a' followed by the letter 'b'. All the description of program is given inside the code as comments.

I hope it will help you!

Explanation:

6 0
3 years ago
I WILL MARK THE BRAINIEST!!!!!!!!!!!!! 50 POINTS!!!!!!!
Sauron [17]
Hello,

Your answer would be:

1. It’s important to have a good study skill so you can be ready to take a quiz such as world history.

2. It’s important to know your time on tasks because you don’t want to spend all day on one simple task you want to get things done.

3. A schedule can help you get organzied because it helps you with your time such as this go along with your second question.

Have a nice day :)

~Rendorforestmusic
5 0
3 years ago
Read 2 more answers
What is the name of the file manager in microsoft windows?
Ivan
It is called Windows Explorer referred as explorer.exe<span />
7 0
3 years ago
Read 2 more answers
Into which of these files would you paste copied information to create an integrated document? A. Mailing list B. Source C. Data
viva [34]

it would be b.mailing list


5 0
3 years ago
Read 2 more answers
Format Painter is used to copy formatting from one location to another.<br> true<br> false
Readme [11.4K]
True

Hope this helps!
4 0
2 years ago
Other questions:
  • Sleeping is an effect of _______ , but agitation may cause a person to wake up
    7·2 answers
  • Why does temperature decrease with higher altitude?
    14·1 answer
  • Declaring a variable in the method’s body with the same name as a parameter variable in the method header is ___________.
    8·1 answer
  • HELP ASAP!!!
    11·2 answers
  • Diane is receiving a lot of unwanted e-mail. What steps can she take to reduce the amount of e-mail she receives?
    12·1 answer
  • Define a new class Fighter that inherits from Spaceship. Add a variable property weapon that defaults to an empty string and a v
    14·1 answer
  • If you see these REPORT.
    14·2 answers
  • When looking at aggregated logs, you are seeing a large percentage of Windows hosts connecting to an Internet Protocol (IP) addr
    5·1 answer
  • Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input
    5·1 answer
  • What is a port?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!