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
Ad libitum [116K]
3 years ago
14

Write the definition of a class Counter containing: An instance variable named counter of type int. An instance variable named l

imit of type int. A static int variable named nCounters which is initialized to 0. A constructor taking two int parameters that assigns the first one to counter and the second one to limit. It also adds one to the static variable nCounters. A method named increment. It does not take parameters or return a value; if the instance variable counter is less than limit, increment just adds one to the instance variable counter. A method named decrement that also doesn't take parameters or return a value; if counter is greater than zero, it just subtracts one from the counter. A method named getValue that returns the value of the instance variable counter. A static method named getNCounters that returns the value of the static variable nCounters.
Computers and Technology
1 answer:
viktelen [127]3 years ago
5 0

Answer:

see explaination

Explanation:

public class Counter

{ int counter,limit;

static int nCounters = 0;

Counter(int a,int b)

{ counter=a; limit=b;

nCounters++;

}

void increment()

{ if(counter<limit)

counter++;

}

void decrement()

{ if(counter>0)

counter--;

}

private int getValue()

{ return counter;

}

private static int getNCounters()

{ return nCounters;

}

}

You might be interested in
2) Please create a C program for the following: (25 points) a. Suppose the US dollar to Korean Won is 0.85 dollars to 1000 won.
Zanzabum

Answer:

In C:

#include <stdio.h>

int main(){

       float won,usd,rupee,dinar,peso;

       printf("Won: ");

       scanf("%f", &won);

       usd = won * 0.85/1000;

       rupee = won * 0.85 * 0.14/1000;

       dinar = won * 0.85 * 0.048/1000;

       peso = won * 0.85 * 1.41/1000;

       printf("USD = %f\n", usd);

       printf("Rupee = %f\n", rupee);

       printf("Dinar = %f\n", dinar);

       printf("Peso = %f\n", peso);

   return 0;

}

Explanation:

This declares all variables as float

float won,usd,rupee,dinar,peso;

This prompts the user for Korean Won

       printf("Won: ");

This gets the input for won

       scanf("%f", &won);

This converts to usd

       usd = won * 0.85/1000;

This converts to rupee

       rupee = won * 0.85 * 0.14/1000;

This converts to dinar

       dinar = won * 0.85 * 0.048/1000;

This converts to peso

       peso = won * 0.85 * 1.41/1000;

The next four lines print the converted currencies

       printf("USD = %f\n", usd);

       printf("Rupee = %f\n", rupee);

       printf("Dinar = %f\n", dinar);

       printf("Peso = %f\n", peso);

3 0
2 years ago
New trends, tools, and languages emerge in the field of web technology every day. Discuss the advantages of these trends, tools,
ikadub [295]

Answer:

Explanation:However, with the emergence of several new web development technologies, tools, frameworks, and languages in the last few years, it has now become quite .

7 0
3 years ago
How do you hack a iPhone, Like If you forgot your password and want to get back in your phone. What do you do?
s344n2d4d5 [400]

Answer:

fix it on itunes

Explanation:

or get a new one

6 0
3 years ago
Read 2 more answers
The new tag in HTML 5 means that it explanation or pronunciation of characters for Asian typography O sets a container for an ex
Eddi Din [679]

Answer:

yes very correctExplanation:

5 0
2 years ago
Assume that d is a double variable. Write an if statement that assigns d to the int variable i if the value in d is not larger t
mamaluj [8]

Answer:

That's because the value has reached the size limit of the int data type. ... you should use long rather than int , because long can store much larger numbers than int . If ... In other words, a float or double variable can't accurately represent 0.1 . ... If you're using Java to measure the size of your house, you'd need an electron ...

Explanation:

3 0
2 years ago
Other questions:
  • I just started game development using unity, I’m trying to control my sphere moving on a flat surface using the W,A,S,D keys, if
    11·1 answer
  • Rate is how fast a screen updates the information being displayed.
    6·2 answers
  • What is the name of the program file that you can enter in the Windows search or Run box to execute Event Viewer? What process i
    12·1 answer
  • Jerry wants to save his company money. He decides to move to open source software for his word processing needs. Jerry then down
    5·1 answer
  • What are the names of the 3 main languages used for making websites
    10·1 answer
  • You’re having trouble connecting to the Internet so you call your Internet service provider for help. They need to know the perm
    15·1 answer
  • An optical fibre has an attenuation of 0.3 dB/km. If a laser launches an optical power level of PIN (mW) into 35 km length of th
    8·1 answer
  • Using existing algorithms as building blocks for new algorithms has all the following benefits EXCEPT
    12·1 answer
  • An end-user license agreement protects _____.
    11·1 answer
  • __________ are very simple devices that connect network components, sending a packet of data to all other connected devices.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!