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]
3 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]3 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
What is the default letter assigned for the primary hard drive?
SVETLANKA909090 [29]

d drive i think unless ssd

8 0
3 years ago
Write a script that will generate random integers in the range from
barxatty [35]

Answer:

Explanation:

Let's do this in Python, we shall use the package random to generate a random double between 0 and 1. Then we multiply it with 50 and covert to integer to get a random integer between 0 and 50. Place a While function with condition to stop when it's greater than 25

from random import random

attempts = 1

random_int = int(random()*50)

print(random_int)

print("This is attempt " + attempts)

while random_int <= 25:

    attempts += 1

    random_int = int(random()*50)

    print(random_int)

    print("This is attempt " + attempts)

5 0
3 years ago
Write a program named CheckMonth that prompts a user to enter a birth month. If the value entered is greater than 12 or less tha
klemol [59]

Answer:

Program:

month=['January', 'Februrary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] #list which stores the name of the month.

CheckMonth= int(input("Enter the number of the month")) #it is used to take the inputs from the user.

if CheckMonth>=1 and CheckMonth<=12: #check the condition for valid month.

   print(str(CheckMonth)+" is a valid month which name is: "+ str (month [CheckMonth-1])) #print the name of month which is enter by the user.

else:

   print(str(CheckMonth)+" is not a valid month, please enter the valid month") # print for the invalid month.

Output:

  • If the user inputs 1, it will prints "1 is a valid month which name is: January".
  • If the user inputs is 0, then it will prints "0 is not a valid month, please enter the valid month"

Explanation:

  • The above program is in python language, in which the first line of the code is used to hold the list of the month.
  • Then the second line is used to render a message for the user input, take the input from the user and save it into a variable.
  • Then that value is checked by the if-condition that it lies in between 1 to 12 or not.
  • If it lies, then print the valid month otherwise it prints that the month is invalid.
3 0
3 years ago
Some Internet users would like to ban Web _____ because they think that its use increases the risks of defamation, fraud, libel,
Law Incorporation [45]

Answer:

anonymity

Explanation:

<h2><u>Fill in the blanks </u></h2>

Some Internet users would like to ban Web <u>anonymity </u>because they think that its use increases the risks of defamation, fraud, libel, and exploitation of children.

5 0
3 years ago
1. Technician A says you can identify a hybrid vehicle by the badging on the engine cover. Technician B says you can identify a
Liono4ka [1.6K]

Answer:

It's B i did the quiz

and got an 100%

Explanation:

Hope this helps :D

6 0
2 years ago
Other questions:
  • Select the correct answer. Richard owns a chain of hardware stores. He wants to update the store website and write a numbered li
    14·1 answer
  • MTTF is a file format developed by Microsoft commonly used on Windows systems; it offers file security, large volume size, large
    11·1 answer
  • Write a program using integers userNum and x as input, and output userNum divided by x four times. Ex: If the input is 2000 2, t
    14·1 answer
  • "A software package developed to handle information requirements for a specific type of business is called a horizontal applicat
    8·2 answers
  • What is the intellectual property
    12·1 answer
  • What is one of the first power tools you’ll need as electrician
    15·1 answer
  • How should you set the OHMS ADJust control on a multitester of analog VOM, for resistance measurements?
    12·1 answer
  • In Outlook 2016, what happens when users begin to type in the To field the name of an email recipient to whom they frequently se
    12·2 answers
  • In what stage of an algae or fungi life cycle are they able to reproduce spores?
    10·1 answer
  • The auto recover function in a word is available to especially if you experience powerful failure explain what happens to your d
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!