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
Jason works as a Help Desk Technician for uCertify Inc. The company has a Microsoft Windows XP-based network. Jason wants to vie
WINSTONCH [101]

Answer:

ipconfig

Explanation:

ipconfig (short for <em>internet protocol configuration</em>) is a command line tool used for determining the network connection configuration of a computer. Some of these configuration information are;

i. the IP address of the computer

ii. default gateway address

iii. subnet mask

iv. Media Access Control (MAC) address.

6 0
3 years ago
Jack, a skillful hacker targeted a major banking services firm located in Japan, using the LOIC (Low Orbit Ion Cannon) tool, Jac
Elenna [48]

Answer:

denial-of-service attack (DoS attack) and distributed denial-of-service attack (DDoS attack)

Explanation:

Denial-of-service attack -

It is a type of cyber attack , where the hacker can create a machine or any network resource , which is capable to disrupt the server of the host , with the help of the internet , is referred to as the denial of service attack .

The task is accomplished with by flooding the host with many superfluous requests , which can overload the system .

In case of the distributed denial-of-service attack , the flooding is done by many different sources .

Hence , from the given scenario of the question ,

The correct answer is  denial-of-service attack (DoS attack) and distributed denial-of-service attack (DDoS attack) .

4 0
3 years ago
Serena, an analyst at an environmental agency, wants to prepare a report using data from the Car Emissions database.
konstantin123 [22]

Answer:

The correct answer is:

Option 1: export the query results from the database to a spreadsheet, then export the graph to a document.

Explanation:

Spreadsheets are used to represent numerical data, perform calculations and display the results numerically or graphically.

When using a database, the query results can be exported to other software using the query web address.

So in order to include the graph in her report, Serena will export the result to spreadsheet and then export the graph to document.

Hence,

The correct answer is:

Option 1: export the query results from the database to a spreadsheet, then export the graph to a document.

5 0
2 years ago
Read 2 more answers
What tasks do most operating systems perform?
devlian [24]

I would say: This is most common.

3, 5, 6

8 0
2 years ago
Read 2 more answers
3. The wildlife department has been feeding a special food to rainbow trout finger lings in a pond. A sample of the weight of 40
andrey2020 [161]

Answer:

1)  402.7 grams. This estimate is called the sample mean.

2)  (399.11, 406.29)

3) The 99 percent confidence limits is between 399.11 grams and 406.29 grams.

I am 99% sure that the value lies between 399.11 grams and 406.29 grams.

Explanation:

sample size (n) = 40, the mean weight (x)= 402.7 grams and the standard deviation (σ)=8.8 grams

1) The point estimated mean weight of the population is 402.7 grams. This estimate is called the sample mean.

2) c = 99% = 0.99

α = 1 - 0.99 = 0.01

\frac{\alpha }{2} =\frac{0.01}{2} =0.005.

The z score of 0.005 corresponds with the z score of 0.495 (0.5 - 0.005).

z_\frac{\alpha }{2} =2.58.

The margin of error (e) = z_\frac{\alpha }{2}*\frac{\sigma}{\sqrt{n} }  =2.58*\frac{8.8}{\sqrt{40} } =3.59

The confidence interval = x ± e = 402.7 ± 3.59 = (399.11, 406.29)

3) The 99 percent confidence limits is between 399.11 grams and 406.29 grams.

I am 99% sure that the value lies between 399.11 grams and 406.29 grams.

8 0
3 years ago
Other questions:
  • State whether true or false.
    6·1 answer
  • What connector has 4 pins, is used for older IDE drives and some SATA drives, and can provide +5 V and +12 V power outputs?
    11·1 answer
  • Help!!!! ASAP TIMED TEST 50 points!!!!
    7·1 answer
  • In windows, a(n) ________ follows the file name and a period and indicates the file type.
    9·1 answer
  • Differentiate Between register and Memory location (
    13·1 answer
  • The force required to slide an object is equal to _____.
    13·1 answer
  • Facts and statistics collected together to be used for different purposes is
    14·1 answer
  • Laptops are used for accessing the internet. Name two advantages and two disadvantages for using a laptop rather than a smartpho
    5·2 answers
  • Which version of java should i use?.
    13·1 answer
  • What is the interface of an app?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!