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
Ron is creating building blocks in Word. How can he make the building blocks that he created available?
daser333 [38]

A) Store those building in Normal template

7 0
3 years ago
Read 2 more answers
0.005098 megaliters to liters. record your answer in whole liters
Dmitriy789 [7]
Your answer would be 5098 liters.

Reason being, because there are 1,000,000 liters in one megalitre, so you just multiply 0.005098 by 1,000,000 to get your answer of 5098 liters.
6 0
3 years ago
Who here has an old (preferably 80s) Toyota Celica i just bought mine and want to know how you guys like yours because mine is f
Maurinko [17]

Answer:

Explanation:

The 1980 Toyota Celica is a great car, it was my first car and I loved it. It has many luxury features that you don't see much in cars of that year. It is also extremely reliable and can take lots of use before beginning to give problems. I used to use it to get to and from school on a daily basis and it never once left me stranded. It includes power steering, cruise control, AC, etc. Not much more you can ask for in a car, it is also a very beautiful looking car, especially a well taken care of one. Enjoy your car.

8 0
2 years ago
Manipulate the SQL statement to pull ALL fields and rows from Customers table that have a PostalCode of 44000. TIP: Since Postal
padilas [110]

Answer:

There are two customers in the PostalCode.

SQL statement for select all the fields and the rows from the Customers table where PostalCode is 44000.

SELECT *  FROM Customers  WHERE PostalCode = "44000";

Explanation:

The SELECT statement retrieve zero or more than one row from 1 or more than one the database tables or the database views.  

In most of the applications, the SELECT query is most commonly used for DQL(Data Query Language) command.  

SQL is the declarative programming language and the SELECT statement specifies the result set, but they do not specifies how to calculate it.

6 0
3 years ago
Florida convicted __________ people of DUI in a one-year period from 2009 to 2010.
natka813 [3]
In 2009 at least 48,516 people were convicted of DUI and in 2010 at least 43,568. Both of the years together adds up to 92,084.

Hope this helps!
3 0
3 years ago
Other questions:
  • Enter the number 2568 into the box below
    14·1 answer
  • Below is a 4-bit down-counter. What is the largest number of the counter if the initial state Q3Q2Q1Q0=0011? (D3 and Q3 are MSB,
    14·1 answer
  • Which of the following website is arguably considered the best site to search for scholarships
    8·2 answers
  • When you insert a photo into a document, its placed at the ​
    13·2 answers
  • Where do charts get the data series names?
    14·1 answer
  • A chemical mixture that is burned to produce thrust. (Jet engine homework)
    14·2 answers
  • Excerpt from "How Prepared Are Students for College Level Reading? Applying a Lexile-Based Approach."
    6·1 answer
  • TRUE OR FALSE: THE BUILDER'S CLUB IS A PAID SUBSCRIPTION.
    9·2 answers
  • If we need to manage a contiguous range of memory, handling requests to allocate various sized chunks, and later make those chun
    12·1 answer
  • To optimize the flow of data into and out of the cpu, the modern mcc provides at least _______________ of data every time the cp
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!