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
Softa [21]
3 years ago
6

Write a full class definition for a class named Averager, and containing the following members:______An data member named sum of

type integer.An data member named count of type integer.A constructor with no parameters. Theconstructor initializes the data members sum and the data member count to 0.A function named getSum that accepts noparameters and returns an integer. getSumreturns the value of sum.A function named add that accepts an integer parameter and returns no value. add increases the value of sum by the value of theparameter, and increments the value of countby one.A function named getCount that accepts noparameters and returns an integer. getCountreturns the value of the count data member, that is, the number of values added to sum.A function named getAverage that accepts noparameters and returns a double. getAveragereturns the average of the values added to sum. The value returned should be a value of type double (and therefore you must cast the data members to double prior to performing the division).
Computers and Technology
2 answers:
alina1380 [7]3 years ago
6 0

Answer:

  1. public class Averager {
  2.    private int sum;
  3.    private int count;
  4.    public Averager(int sum, int count) {
  5.        this.sum = 0;
  6.        this.count = 0;
  7.    }
  8.    public int getSum(){
  9.        return sum;
  10.    }
  11.    public void add( int num){
  12.        this.sum+=num;
  13.        this.count++;
  14.    }
  15.    public int getCount(){
  16.        return this.count;
  17.    }
  18.    public double getAverage(){
  19.        double ave = (int)this.sum/this.count;
  20.        return  ave;
  21.    }
  22. }

Explanation:

  • Lines 1-3 contains the class declaration and the member (data fields)
  • Lines 4-7 is the constructor that initializes the fields to 0
  • Lines 8-10 is the method that returns the value of sum getSum()
  • lines 11-14 iss the method add() that adds a number to the member field sum and increases count by 1
  • lines 15 - 17 is the method that returns total count getCount()
  • Lines 18-21 is the method getAverage() That computes the average and returns a double representing the average values

balandron [24]3 years ago
3 0

Answer:

#ifndef AVERAGER

#define AVERAGER

class Averager{

public:

int sum;

int count;

Averager(){

sum = 0;

count = 0;

}

int getSum(){

return sum;

}

void add(int n){

sum += n;

count++;

}

int getCount(){

return count;

}

double getAverage(){

return (double)sum/count;

}

};

#endif

Explanation:

You might be interested in
Opportunities in nanotechnology apply broadly to many fields. Identify TWO areas of IT that may be impacted by its further devel
Soloha48 [4]

Answer:

a. quantum computing and telecommunications

Explanation:

Both quantum computing and telecommunications need materials with specific optical, electrical, and magnetic properties to advance, and nanotechnologies open the opportunity for nanomaterial with incredible properties. From antennas with special magnetic properties to faster optical fiber from more stable material to store qubits to super thermal insulators, nanotechnologies will change the way we build and design telecommunication systems, and it will allow us to build stable and reliable quantum computers.

7 0
3 years ago
Which windows system include new features and extends the functionality
Juli2301 [7.4K]

Critical update

Hope this helps!

3 0
3 years ago
Write a Python program to convert the characters to lowercase in a string
wel

Answer:

Following is the program in the python language

st = 'sAN RaN'  #String

print(st.lower()) #display into the lowercase

Output:

san ran

Explanation:

Following are the description of program

  • Declared and initialized the string in the "st" variable .
  • The lower function in python is used for converting the uppercase string into the lower case string .
  • Finally in the print function we used lower function and display the  string into the lower case
8 0
3 years ago
Select the properties of the sn1 reaction mechanism.
musickatia [10]

It is - not stereospecific , a reaction in which the stereochemistry of the reactants controls the outcome of the reaction; - bimolecular at rate-determining step , it involves two molecules; - first order, - rates is governed by the stability of the carbocation that is formed.

7 0
3 years ago
Why is stranded rather than solid cable used for patch cables? Why is it critical not to score the jacket too deeply when stripp
Serggg [28]

Answer:

The definition of the issues is listed throughout the section down.

Explanation:

  1. Stranded cables are somewhat more compact and can be mounted quickly. Strong cables become rigid in design, and they are not versatile for installation. In comparison with solid connectors, amplification is indeed high.
  2. Unless the innermost layer including its wire is broken as we attempt to connect the cable, it will not function. So, whenever stripping the cables through the walls, it's indeed important not to rank the jack too profoundly.
  3. It would be quick to untwist the cable and then will ensure that perhaps the connection is appropriate for the most widely encountered rj-45 connection whenever the wiring of 0.5 inches becomes coupled up.
  4. If we don't keep the right pin colors in order, the relation won't work. Afterward, when another connexon is broken due to many complications, it would be impossible to figure out the contacts unless the pins coloring are not always in sequence.
  5. The connection pairs can be cut off through 0.5 inches within about therefore the gap within the connector is narrower and the wire would not be correctly attached if we break the cable further. The link is lost and the cable does not run properly.
  6. It is necessary to ensure that perhaps the wires are forced to the end of the platform since the connexon will indeed be broken as well as the connector would not operate unless the wires aren't moved. The wires will fall out of another socket as well.
  7. Before even being incorporated into another crimping unit, it is good to carefully check the connection sequence to ensure that perhaps the wires are to the end since it is impossible to verify the sequence until the wires are attached to something like the connector. Unless the connections are not always in alignment, the link will also not be provided and indeed the wire would not operate correctly, even if the link is provided. Such wires can also be presented to use load barriers, and that it's the simplest operation.
  8. The Durability Tester has been used to determine the hardness between two stages, whereas the connection efficiency is tested using the qualification tester.

8 0
3 years ago
Other questions:
  • Motorcycles have two or three wheels, a seat for the rider and at least a ____ horse-powered engine.
    15·1 answer
  • What is the output of the following program when the method is called with 4?
    11·1 answer
  • What is the decimal representation of the following signed binary numbers?
    6·1 answer
  • 6. What is the difference between portrait and landscape orientation? What are the advantages of
    9·1 answer
  • __________ are the first line of defense against unsafe drivers.
    5·1 answer
  • One condition for deadlocks is the circular-wait condition. One way to ensure that this condition never holds is to impose a tot
    12·2 answers
  • Numerical methods are implementations of mathematical algorithms, but constructed with special consideration for accuracy of sol
    7·1 answer
  • I need help thanks please!
    8·2 answers
  • OSI layer for HDLC??​
    13·1 answer
  • python. create a program that asks the user to input their first name and their favorite number. Then the program should output
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!