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
Evgesh-ka [11]
4 years ago
7

Write a full class definition for a class named Counter, and containing the following members: A data member counter of type int

. A data member named limit of type int. A static int data member named nCounters which is initialized to 0. A constructor that takes two int arguments and assigns the first one to counter and the second one to limit. It also adds one to the static variable nCounters A member function called increment that accepts no parameters and returns no value. If the data member counter is less than limit, increment just adds one to the instance variable counter. A member function called decrement that accepts no parameters and returns no value. If counter is greater than zero, decrement subtracts one from the counter. A member function called getValue that accepts no parameters. It returns the value of the instance variable counter. A static function named getNCounters that accepts no parameters and returns an int. getNCounters returns the value of the static variable nCounters.
Computers and Technology
1 answer:
vfiekz [6]4 years ago
4 0

// making the class

class Counter {

int counter;

int limit;

// Constructor

Counter(int a, int b){

counter = a;

limit = b;

}

// static function to increment

static increment(){

if(counter<limit)

nCounter+=1;

}

// Decrement function

void decrement(){

if(counter>0)

nCounter-=1;

}

int getValue(){

return counter;

}

static int nCounter;

int getNCounters(){

return nCounter;

}

};

// Initializa the static

int Counter::nCounter = 0;

You might be interested in
When following proper netiquetter rules you should follow all of the following rules except _____. Question 11 options: Don't us
vfiekz [6]

The answer is C. Use sarcasm and jokes in your e-mails to make the reader laugh


Sarcasm and jokes can be difficult to understand through text-based communication like e-mails, so it is best to avoid them altogether, especially in formal settings.

6 0
3 years ago
Read 2 more answers
When is Hytale coming out?<br><br><br> P.S it might be Mine-craft 2.0<br><br><br> :)
cluponka [151]

No release date has been announced and there's only speculation. My best guess would be maybe Spring or Summer of this year

8 0
4 years ago
Write a full class definition for a class named Averager, and containing the following members:______An data member named sum of
alina1380 [7]

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

6 0
4 years ago
Read 2 more answers
A Supermarket manager hired one packager who can pack 15 boxes every two minutes. Ater some time the manager noticed that packag
Semenov [28]

Answer:

40mn

Explanation:

500/t=15/2+15/3

500/t=75/6

75t=500×6

t=3000/75

t=40

6 0
3 years ago
Read 2 more answers
Describe the seven layers of the OSI Reference Model.
kvv77 [185]

Answer:

i hope this helps you

Explanation:

6 0
3 years ago
Other questions:
  • ¿cuales son la diferencias de programacion estructurada y programacion orientada a objetos?
    10·1 answer
  • (08.03 MC) Maya is a senior in high school and would like to pursue a career in web design. She needs more information about wha
    11·2 answers
  • Write a calculator program that keeps track of a subtotal like real calculators do. Start by asking the user for an initial numb
    12·1 answer
  • Insert the missing code in the following code fragment. This fragment is intended to read an input file named dataIn.txt and wri
    13·1 answer
  • The human brain can store both temporary and permanent bits of information. Which type of memory in the computer is similar to t
    6·1 answer
  • Does unturned game is good for low end PC that without graphics card?​
    5·1 answer
  • Anyone wanna hop on 1v1.lol<br> party code : usfhb6
    12·2 answers
  • How do ACLs work on a router?
    9·1 answer
  • During slide show mode, hitting the B key will do which of these things? end your presentation move back one page move to the fi
    15·1 answer
  • The UIDs for a set of hierarchical entities can be propagated through multiple ________ relationship
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!