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
What will be the output of the following program? Assume the user responds with a 5.
FrozenT [24]

The output will be: You owe $ 15.0

4 0
3 years ago
For your biology class, you have taken a number of measurements for A plant growth experiment. you wish to create a chart that s
Natasha2012 [34]
The answer is B, calc or excel
4 0
3 years ago
An algorithm to display multiplication table a number up to 12​
kkurt [141]

Explanation:

Explanation:They are

Explanation:They are 1) start the process

Explanation:They are 1) start the process 2) Input N, the number for which multiplication table is to be printed

Explanation:They are 1) start the process 2) Input N, the number for which multiplication table is to be printed 3) For T = 1 to 10

Explanation:They are 1) start the process 2) Input N, the number for which multiplication table is to be printed 3) For T = 1 to 104) print M = N*T

Explanation:They are 1) start the process 2) Input N, the number for which multiplication table is to be printed 3) For T = 1 to 104) print M = N*T5) End for

Explanation:They are 1) start the process 2) Input N, the number for which multiplication table is to be printed 3) For T = 1 to 104) print M = N*T5) End for6) Stop the process

4 0
2 years ago
A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost
makvit [3.9K]

Answer:

milk_produced = float(input("Enter the total amount of milk produced in the morning: "))

liter_cost = float(input("Enter the cost of producing one liter of milk: "))

carton_profit = float(input("Enter the profit on each carton of milk: "))

carton_needed = round(milk_produced / 3.78)

cost = milk_produced * liter_cost

profit = carton_profit * carton_needed

print("The number of milk cartons needed to hold milk is " + str(carton_needed))

print("The cost of producing milk is " + str(cost))

print("The profit for producing milk is " + str(profit))

Explanation:

*The code is in Python.

Ask the user to enter milk_produced, liter_cost and carton_profit

Calculate the number of milk cartons needed, divide the milk_produced by the capacity (3.78) of a cartoon and round the result

Calculate the cost, multiply the milk_produced by liter_cost

Calculate the profit, multiply the carton_profit by carton_needed

Print the results

3 0
3 years ago
Some problems are better solved by a computer and some are better solved by humans.
aalyn [17]

Answer:

I say when u don't know the answer completly.

3 0
2 years ago
Other questions:
  • How many bytes make up a megabyte? One hundred One thousand One million One billion
    12·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • . Two or more functions may have the same name, as long as their _________ are different.
    9·1 answer
  • Data_____is defined as the condition in which all of the data in the database are consistent with the real-world events and cond
    9·1 answer
  • What is an online reputation?
    12·2 answers
  • Which answer would it be?
    12·1 answer
  • 14 Convert the<br>following binary<br>numbers to decimal <br>0011​
    10·2 answers
  • Exercise : Randomizer In this exercise, we are going to create a static class Randomizer that will allow users to get random int
    14·1 answer
  • Which three techniques are used in this photo
    12·1 answer
  • Please i need help here.. am giving brainliest.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!