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]
4 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]4 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]4 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
A minor with prior convictions of Minor in Possession (MIP) who is charged with a subsequent MIP may be penalized with a jail se
GarryVolchara [31]
The minor may be penalized with a jail sentence of up to thirty days for his second offence.  A jail sentence of up to sixty days is possible for third offence. Under MCL 436, a minor is someone who is under twenty one years old. Such minors may not purchase, consume or be in possession of any alcoholic liquor. Possession of alcoholic drinks can be actual or constructive. It is actual when you have direct physical control over it and it is constructive when you know where it is and you have reasonable access to it.
3 0
3 years ago
Read 2 more answers
Evaluation, formatting, expanding/decoding, distillation/reduction, and assessment are examples of ________ computing operations
Pavlova-9 [17]

Evaluation, formatting, expanding/decoding, distillation/reduction, and assessment are examples of <u>fog</u>  computing operations.

The correct option is C.

<h3>What is computing operations?</h3>

An action that is taken in computing to complete a certain task is referred to as an operation. The five fundamental categories of computer operations are input, processing, output, storing, and control. The five major functional components of a computer system each carry out one or more computer activities.

<h3>What are the basic computing operations?</h3>

Arithmetic and logical operations are the two primary sorts of work that CPUs carry out. In contrast to logical operations, which compare two numbers, arithmetic operations involve basic math concepts like addition and subtraction.

<h3>What is  fog  computing operations?</h3>

Both 5G and fog computing

Fog computing refers to a type of computer architecture in which a network of nodes continuously collects data from Internet of Things (IoT) devices. These nodes have millisecond response times and process data in real-time as it comes in. Every so often, the nodes communicate to the cloud analytical summary data.

To know more about computing operations visit:

brainly.com/question/18095291

#SPJ4

I understand that the question you are looking for is:

Evaluation, formatting, expanding/decoding, distillation/reduction, and assessment are examples of ________ computing operations.

A) OpenStack

B) cloud

C) fog

D) RFID

8 0
2 years ago
Self-disclosure is most likely to occur _____________.a.
Feliz [49]

The answer is..

C.  During one-on-one conversations

4 0
3 years ago
Read 2 more answers
Write a class named Car that has the following data attributes:
meriva

ANSWER

The program in JAVA for the given scenario is as follows.

import java.util.*;

public class Car

{

// variables declaration

   static int _year_model;

   static String _make;

   static int _speed;

   

   public static void _init_( int model, String m )

   {

// variables initialization

       _year_model = model;

       _make = m;

       _speed = 0;

   }

   

   public static void accelerate()

   {

       _speed = _speed + 5;

   }

   

   public static void brake()

   {

       _speed = _speed - 5;

   }

   

   public static int get_speed()

   {

// current value of speed is returned

       return _speed;

   }

   

public static void main(String[] args) {

     

    // object of class created

    Car ob = new Car();

     

    // method called using object of class

    ob._init_(2019, "audi");

     

    ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 

 System.out.println();

 

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 

}

}

OUTPUT

Accelerated speed 5

Accelerated speed 10

Accelerated speed 15

Accelerated speed 20

Accelerated speed 25

Speed after brake 20

Speed after brake 15

Speed after brake 10

Speed after brake 5

Speed after brake 0

EXPLANATION

1. Variables are declared with String and integer datatypes.

2. _init_() initializes all the variables. This method is also called inside main() using object of Car class in order to initialize the variable speed to 0.

3. Inside main(), object of Car class created.

Car ob = new Car();

4. All the methods are called using object of the class.

ob._init_(2019, "audi");

ob.accelerate();

ob.brake();

5. All the variables are declared as static.

6. All the methods are declared as static since main() method is static inside which all other methods are called.

7. New line is included to improve readability of the output.

7 0
4 years ago
What is the total resistance in a circuit that contains three 60 ohm resistors connected in a series?
nignag [31]
I think it is D 180
5 0
4 years ago
Read 2 more answers
Other questions:
  • A delimiter is used to do which of these? A. Separate two lines of data from each other. B. Separate two fields within a line of
    9·2 answers
  • Somebody who is good at this stuff, please halp meh ;-;
    6·1 answer
  • For which is a chart Legend used
    5·2 answers
  • In 3-4 sentences, write a note to a friend describ
    6·2 answers
  • What does CRM stand for?
    10·1 answer
  • Define the four basic operation of a computer ​
    6·1 answer
  • When you cut and then paste a file, what are you doing?
    7·2 answers
  • Dana is moving to a new house. She has 15 boxes for books. Each box can hold up to 22 books. Dana has 375 books. How many more b
    10·2 answers
  • Write javascript code for the form that appears in the image below. you are expected to add validation to the name field, email
    10·2 answers
  • the set of methods that can be used to acquire, organize, store, manipulate, and transmit information is known as .
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!