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]
4 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]4 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]4 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
Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
qaws [65]

Answer:

Se explaination

Explanation:

/Declaring variables

integer currentPrice

integer lastMonthPrice

integer changeLastMonth

float mortagage

//Reading input

currentPrice = Get next input

lastMonthPrice = Get next input

//Calculating price change

changeLastMonth = currentPrice - lastMonthPrice

//Calculating mortagage

mortagage = (currentPrice * 0.051) / 12

//Printing output

Put "This house is $" to output

Put currentPrice to output

Put "\nThe change is $" to output

Put changeLastMonth to output

Put " since last month." to output

Put "\nThe estimated monthly mortgage is $" to output

Put mortagage to output

3 0
3 years ago
A metacharacter is a character that has a special meaning assigned to it and is recognized as part of a scripting or programming
nydimaria [60]

Answer:

The answer is "Option a"

Explanation:

Meta-character is a unique character, which is used in the system or information area, that provides information about the other characters. This type of character is used in both command-line and programming.  

  • It has a particular meaning and should be prevented for reasons except for its particular importance.
  • It attempts in the algorithmic technique to view all character as a fundamental ASCII instead of a specific purpose.
3 0
3 years ago
Name 3 examples of operating system software that are not Windows based.
anyanavicka [17]
Ubuntu, Linux, and Mint
4 0
3 years ago
Which best describes this future of. Employment in the. Energy career cluster
Aloiza [94]

Answer:its A

Explanation:

just took the quiz

3 0
3 years ago
Ray has to type an invoice using the QWERTY keyboard. Along with letters and numbers, he also has to insert the dollar sign. Whi
olganol [36]

Answer:

Shift and 4 at the same time, or hold shift and press 4.

4 0
3 years ago
Other questions:
  • A company that manufactures machine parts order a new system that makes Products at ten times the speed of earlier machines. the
    13·2 answers
  • A virus is a name given to a small text file that's placed on your computer by the designers of the website when you visit that
    6·1 answer
  • A _____, or spider, is a search engine program that automatically searches the web to find new websites and update information a
    14·1 answer
  • Identify methods to improve programming skills.
    15·1 answer
  • Microsoft edge A. Is a newer version of internet explorer B. Works well with safari C. Was designed for apple products D. Is a s
    8·2 answers
  • I’ll mark who ever is first or last Doesn’t matter JUST PLEASE HELP
    8·1 answer
  • You have been given an encrypted copy of the Final exam study guide here, but how do you decrypt and read it???
    7·1 answer
  • 1. Give one reason why data is represented in binary in a computer [1]
    10·1 answer
  • A company has employees who write down passwords, which should be kept private, on sticky notes. Given this scenario, what shoul
    12·1 answer
  • Recently, from around june through september 2022, a social engineering campaign, attributed to a nation-state group, has been u
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!