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
The company generates a lot of revenue and is rapidly growing. They're expecting to hire hundreds of new employees in the next y
uysha [10]

Answer:

The most appropriate way to deal with the situation presented above is to acquire more space at the current office site at additional rent beforehand.

Explanation:

The Scaling of a revenue-generating business is a crucial task in which a lot of pre-planning and thinking is required.

In order to scale the business in the next year, the planning of it is to be carried out at the moment and proper necessary arrangements are ensured. These steps could be one from:

  • Looking for bigger spaces for renting for a full shift of the operations
  • Looking for a site office for an additional office
  • Acquiring more space in the current office site.

This process would result in acquiring a bigger place beforehand but in order to mitigate the risk, try to keep the place in view by providing them a bare minimum advance for the additional units.

8 0
3 years ago
Which processor interrupts the system 18.2 times per second? What are some of its practical uses?
julsineya [31]

Answer:

timer interrupt

Explanation:

A timer is an interrupt that is generated by the PC's system timer.When this interrupt occurs, the ROM BIOS interrupt handler is called and it increments a count in the ROM BIOS.It interrupts the system 18.2 times per second.It is used for multitasking.Hence we conclude that timer interrupt is the answer.

6 0
3 years ago
Allie needs to add a long row of numbers. She should enter a
ikadub [295]
I believer the answere is a formula hope this helped
8 0
2 years ago
Read 2 more answers
By default, PowerPoint ends a slide show with a black slide. <br> a. True<br> b. False
Dmitry [639]
True . Because Press " ESC " To Exit Off Of Slide . 
5 0
3 years ago
Read 2 more answers
The bank has a website that’s been attacked. The attacker utilized the login screen, and rather than entering proper login crede
RoseWind [281]

Answer:

C.SQL Injection

Explanation:

C.The text shown is the classic example of a basic SQL injection to log into a site

7 0
3 years ago
Other questions:
  • Find and record a set of instructions containing a repetition clause (e.g., instructions on a shampoo bottle, a recipe, etc.). H
    11·1 answer
  • Multiple users report that the network printer, which is connected through the print server, is not printing. Which of the follo
    12·1 answer
  • Recently, your laptop won't power on, and the battery is not charging. You suspect the block on the power cord (also known as a
    5·1 answer
  • All computers perform disk optimization utilizing the same software.<br><br> true <br> false
    11·1 answer
  • Read the scenario below, and then answer the question.
    13·1 answer
  • Xercise 1<br>1.<br>What is system? Explain the components of system in brief.​
    12·1 answer
  • In this exercise, you are asking the user to set a alpha numeric password for any website. Put some conditions.
    8·1 answer
  • Graphics created within Illustrator CC are always vector graphics true or false
    9·1 answer
  • Group of programs are software <br>​
    11·1 answer
  • What is the most common knowledge computer programmers need in order
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!