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
Kisachek [45]
3 years ago
6

Write a class named Averager containing: An instance variable named sum of type integer, initialized to 0. An instance variable

named count of type integer, initialized to 0. 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 and the value of count is incremented by one. A method named getCount that accepts no parameters. getCount returns the value of the count instance variable, that is, the number of values added to sum. A method named getAverage that accepts no parameters. getAverage returns the average of the values added to sum. The value returned should be a value of type double (and therefore you must cast the instance variables to double prior to performing the division).
Computers and Technology
1 answer:
vladimir1956 [14]3 years ago
3 0

Answer:

The answer to this question can be given as:

Class definition:  

public class Averager  //define class Average.

{

private int sum = 0;

 //define variable sum.

private int count = 0;

 //define variable count.  

public int getSum() //define function getSum().

{

return sum;  //return value.

}

public void add(int x)

//define function add().

{

sum = sum + x;   //calculate sum

count=count+1; //increase value of count.

}

public int add(int x)

 //define function add().

{

return count;  //return value.

}

public double getAverage()  //define function getAverage().

{

return (double)sum/count;  //return value

}

}

Explanation:

The above class definition can be described as:

  • In the above class definition first we define a class that is " Averager". In this class we define two integer variable  that is "sum and count"  and assign a value that is 0. Then we define a functions :
  • First we define getSum() function in this function we does not pass any value and the return type of this function is int that will return an integer value.
  • Then we define add() function we use this function two times but both functions have different from each other.  
  • In first time implementation, we define this function and the return type of this function is void which means it does not return any value. In this function, we calculate the sum value and increase the value of the count variable by 1.  
  • In second time implementation, we define this function and the return type of this function is int which means it will return a value. In this function, we will return the count variable value.
  • At the last, we define a getAverage() that calculates the average of the added values in the sum variable and returns its value.
You might be interested in
Which image-editing tool can be used to help remove spots and other marks from an image?
Mrac [35]
C. Healing brush
That’s the answer
5 0
3 years ago
which of the following scenarios is a circumstance in which it would be ethical to practice confidentiality?
Citrus2011 [14]
Hi. I am not sure if there should be choices included in your post. If there is none, I'll just share a circumstance to where a professional practices confidentiality as an answer. 

Counselors or psychotherapists can only divulge information about their clients or patients if there is a court order or if the client will harm him/her self or plan to harm others. Primarily, they are to respect the client's choice to keep the sessions with full confidentiality. 
4 0
3 years ago
C. you have already verified the routing table entries for r1, now execute the show run | section interface command to verify vl
lilavasa [31]
Help help help i have same questions

5 0
4 years ago
Suggest a reason why it was constructed there?​
valina [46]
Can you post the work assigned so I can better understand?
6 0
3 years ago
Networks that are designed to connect similar computers that share data and software with each other are called:_______
sergij07 [2.7K]

Networks that are designed to connect similar computers that share data and software with each other are called: Peer to Peer (P2P) Networks.

<h3>What is a networking software?</h3>

A networking software can be defined as a set of executable instructions (codes) that is typically designed and developed to instruct a networking device on how to perform a specific task or transmit data from one location to another.

<h3>The types of networking software.</h3>

Generally, there are three main types of networking software and these include the following:

  • Security software
  • Connection software
  • Transport software

In Computer networking, Peer to Peer (P2P) Networks can be defined as a type of network that are designed and developed to connect similar computers that share data and software with each other.

Read more on Peer to Peer Networks here: brainly.com/question/1932654

#SPJ1

7 0
2 years ago
Other questions:
  • A company that hires only American Indians is practicing
    5·2 answers
  • What type of scientists studies tree rings to determine the history of an area?
    9·2 answers
  • Data silos are often associated with ________________.
    12·1 answer
  • which field in the contact form is used to control the order in which contacts are displayed in the current view
    15·1 answer
  • What are ways to enter formula in Excel? Check all that apply
    8·2 answers
  • Minerals can form deep inside Earth’s crust by
    13·1 answer
  • 2) [13 points] You’ve been hired by Banker Bisons to write a C++ console application that determines the number of months to rep
    8·1 answer
  • Which device do engineers use to drive a system of gears?
    15·2 answers
  • 4.1 code practice python
    13·1 answer
  • A processor's speed is measured in megahertz (MHz), or millions of instructions per second; and gigahertz (GHz), or billions of
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!