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
This tag is used to change the appearance of your text on your web page
zaharov [31]

Answer:

b.font tag

is used to change the appearance of your text on your web page

8 0
3 years ago
The leader of the team wants to do everything him or herself. They have a very big ego and are difficult to work with. What is t
JulijaS [17]

Answer:

The problem is the team leader thinks he/she is better than other team members?

Explanation:

He/She thinks or to show that no other team leader is as good as him/her.

7 0
3 years ago
What is the symbol that causes the computer to perform string concatenation?
neonofarm [45]

Answer: In java the symbol "+" operator is used to perform string concatenation.

Explanation:

String concatenation refers to joining of two strings. So in java + is used to join strings which works provided one of the operands must be a String variable. Then it works by converting the other variable to String variable and joins the second operand to the end of the first operand.

An example of String concatenation is as follows:

int age = 10;

System.out.println("The boys age is " + age);

Output:

The boys age is 10.

here, the age is integer variable but as the phrase "The boys age is" is a String variable so it converts the age to String variable and joins both the Strings.

4 0
3 years ago
Two floating point numbers, A and B, are passed to a recursive subroutine.
Mnenie [13.5K]
The answer is (c) infinite loop
6 0
4 years ago
In the bussiness cycle which term best fits the labeled point on the graph
andrew11 [14]
In the business cycle, the term that best fits the labeled point on the graph of Production output vs Time is Contraction
8 0
2 years ago
Other questions:
  • Which of the following was one of the first internet search engines? A. archie B. google C. Yahoo D.ask
    7·1 answer
  • Who was eqvtime tayaishvili?​
    13·2 answers
  • Which of the following economic systems leaves production decisions completely up to the producers?
    15·2 answers
  • Which is the correct process for attaching a file?
    12·1 answer
  • How many license plates are there if a license plate contains 3 letters from the 26 available in the English alphabet followed b
    15·1 answer
  • Photography is harder with digital cameras than with film cameras.<br>true<br>false
    6·2 answers
  • You compared each letter in the correct word to the letter guessed.
    5·1 answer
  • A restaurant recorded the ages of customers on two separate days. You are going to write a program to compare the number of cust
    5·1 answer
  • Colorful bead bracelet in codehs
    14·1 answer
  • What is a simple definition for electricity?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!