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
Consumers who wish to make a purchase from other consumer on ebay need tl
il63 [147K]

Answer:

Bid on item

Explanation:

Consumers who wish to make a purchase from other consumer on ebay need to first of all bid on the item. This is done by specifying the price in which the purchase should be made.

When this is done, the seller contacts the buyer if he/she’s okay with the price of the goods and services and other formalities are discussed.

8 0
3 years ago
What is the statement describing? Agile team continuously adapt to new circumstances and enhance the methods of value delivery
Vera_Pavlovna [14]

Answer:

Continuous Integration

Explanation:

In continuous integration process, A program or piece of code is edited, tested and validated by team of software developers or contributors to complete and deploy the single project. This practice will improve the quality and reliability of the code.

Improvement, delivery and deployment are the three different phases, to complete the process of continuous integration.The individuals who contribute in a code or program  in terms of improvement, delivery and deployment make a team that leads to continuous integration.

So, Agile team Continuously adapt Continuous Integration to new circumstances and enhance the methods of value delivery.

8 0
3 years ago
Where do you place the logical test argument in an IF function formula?
Inessa [10]

Answer:

The first argument listed after IF

Explanation:

When the two variables are listed next to each other, Excel will find and calculate the correlation between them.

8 0
3 years ago
Read 2 more answers
What were the important developments that occurred in photography that facilitated the creation of motion pictures? Two critical
8_murik_8 [283]

Answer:

"A moving picture is an illusion that makes a still photo seem to move. The basic principal behind motion pictures is the fast transition between one picture to the next, almost creating a seamless transition. A flip-book is a good example of this. Another example would be film used for old movies. The film contains negatives of an image which when light is shined through creates a "shadow" of the image. If you quickly transition the film from one image to the next you end up a motion picture."

Explanation:

7 0
3 years ago
US-CERT is a set of moderated mailing lists full of detailed, full-disclosure discussions and announcements about computer secur
n200080 [17]

Answer:

False

Explanation:

BugTraq is a high volume, full disclosure mailing list for the detailed discussion and announcement of computer security vulnerabilities, not US-CERT

3 0
2 years ago
Other questions:
  • What is “centrifugal bumble puppy”? why is it important for games to require a complicated apparatus?
    10·2 answers
  • Category 6 is an example of a ________ used to connect wired network devices.
    9·1 answer
  • what type of clause must you always use with DEKETE or UPDATE to avoid inadvertently changing data elsewhere in the database​
    12·1 answer
  • Which port-authentication network access control standard forces devices to go through a full authentication, authorization, and
    13·1 answer
  • The person in charge of recording the sound should always
    15·1 answer
  • The administrators of Tiny College are so pleased with your design and implementation of their student registra- tion and tracki
    13·1 answer
  • ANYBODY WANNA PLAY FoRnITe
    11·2 answers
  • In what way, if any, has community building changed in the age of digital media? People’s community building has not changed in
    13·1 answer
  • WILL GIVE BRAINLIEST ANSWER!!!<br><br> How do you manage your screen time?
    8·2 answers
  • Suppose you are working in a computer lab during the work you are facing window failure or other technical issues.How you will s
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!