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
Complete the following statement: Sustainability is: Choose all that apply.This task contains the radio buttons and checkboxes f
const2013 [10]

Answer:

E. Leading the way to a new kind of future for the environment, the economy, and society.

Explanation:

We can look at Sustainability to mean the way of meeting our own needs without compromising the ability of future generations to meet their.

In sustainability the focus is not on the now only, rather it puts into consideration the fate the future generation will face.

Hence, it is Leading the way to a new kind of future for the environment, the economy, and society.

8 0
3 years ago
You have a server called server1 that is running windows server 2012. what command would you use to delete the ptr record for 10
dybincka [34]
You could use th dnscmd server1 /recorddelete command that would allow you to delete record through powershell
3 0
3 years ago
A network administrator has been creating a baseline of network performance. During this process, he realizes that one router is
LiRa [457]

If the network administrator found that one of his routers is slow in performance better to check the traffic packet transactions. If any huge file size is been transferred better to disconnect the router and reconnect.

Possible to kill the network task packet so the network speed can be restored.

<u>Explanation:</u>

Moreover, possible to scan the end-user PC or workstation or desktop whether any malware or spyware is affected, if so better to remove that particular PC or workstation or desktop to disconnected from the router.

Updating the PC or workstation or desktop OS patches to be done at regular intervals.

5 0
3 years ago
Suppose you are currently in the /home/hnewman/os/fall/2013 directory and would like to navigate to /home/hnewman/discreteStruct
Alex Ar [27]

Answer:

C

Explanation:

ive been doing this same one so its C

6 0
3 years ago
What are the data types used in C programming with examples
Zepler [3.9K]
I don’t really understand what you are trying to ask. Try posting a picture along with your question
5 0
3 years ago
Other questions:
  • Whereas lines of competition are clearly defined in the more established industries, in the Internet industry they are blurred a
    9·1 answer
  • Notes page view and Outline view are found in the<br> tab.<br> File<br> O Status<br> View<br> Page
    8·1 answer
  • Name a computer programme that designers are likely to use to create a leaflet advertising their new product
    15·1 answer
  • A culture that emphasizes verbal communication skills is ____________.
    9·2 answers
  • You disassemble and reassemble a desktop computer. when you first turn it on, you see no lights and hear no sounds. nothing appe
    11·2 answers
  • During the ________ phase of the systems development life cycle process, developers construct, install, and test the components
    13·1 answer
  • Suppose that class OrderList has a private attribute double cost[100] which hold the cost of all ordered items, and a private at
    14·1 answer
  • "A user reports that the corporate web server cannot be accessed. A technician verifies that the web server can be accessed by i
    8·1 answer
  • HURRY!!!!!!!!!!!!!
    15·1 answer
  • What videos do you think we should make next?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!