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
How many functions can Excel perform?
Vlad [161]

Answer:

G

Explanation:

because

3 0
4 years ago
As a prospective student, what is the best reason to request an interview with your college application?
weqwewe [10]

Answer: The correct answer is A. I just answered this question myself!

6 0
3 years ago
A security administrator has replaced the firewall and notices a number of dropped connections. After looking at the data the se
Nata [24]

Answer:

The correct answer is Option(A) i.e., An SQL injection attack is being

attempted.

Explanation:

In this given question some information is missing and is not the complete question. The missing is given as :

SELECT * FROM and ‘1’ = ‘1’

Which of the following can the security administrator determine from this?

A. The SQL injection attacked is being attempted.

B. An Legitimated connections is being dropped.

C. The network scan are being done by the system.

D. An attack of XSS is being attempted.

Now, coming to the answer "The security administration sees that an SQL injection is attempted while it notices a lot of connection dropped and has replaced with the firewall and will be the possible issue flagged on it, SQL injection is a type of injection that possibly executes harmful or malicious statements and effects any website or web application".

Hence the correct answer is Option A.

5 0
3 years ago
Which technology is used to uniquely identify a wlan network?
expeople1 [14]
The answer is SSID

SSID which in full stands for Service Set Identifier is used to identify a network. It ensures that clients are able to locate a WLAN in which they are attached to. In Layman’s terms, it’s the username or the primary name in a WiFi setup in which a user joins and is connected to.






8 0
3 years ago
Web page typically contains _______, which contains the formatting instructions for displaying the web pag
MatroZZZ [7]

The answer in the blank is HTML or also referred to as Hypertext Markup Language as this is always included with the World Wide Web pages for they are always essential and needed. It is because it is a standardized system that would help the resources of the internet that is to be displayed on the page.

6 0
3 years ago
Other questions:
  • Not all products are well suited for sale on the internet. T or F
    11·2 answers
  • A _________ is the broadcast of various types of media over the web.
    10·2 answers
  • Is there a way to search your computer for all music files on it?
    9·1 answer
  • Which loan type requires you to make loan payments while you’re attending school?
    7·1 answer
  • What do you think is the most fascinating aspect of the internet?
    14·1 answer
  • Using C#, declare two variables of type string and assign them a value "The "use" of quotations causes difficulties." (without t
    11·1 answer
  • Write only in C, not C++.
    14·1 answer
  • TRY IT Choose the Right Technology MP3 player Widescreen laptop computer Smartphone Tablet computer with wireless Internet Suppo
    8·2 answers
  • Summarize the four critical issues for cyber warfare.
    6·1 answer
  • How did transistors revolutionize the world of computers?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!