subject

Calculator class In the file Calculator. java, write a class called Calculator that emulates basic functions of a calculator: add, subtract, multiply, divide, and clear. The class has one private member field called value for the calculator's current value. Implement the following Constructor and instance methods as listed below: public Calculator() - Constructor method to set the member field to 0.0
public void add(double val) - add the parameter to the member field
public void subtract(double val) - subtract the parameter from the member field
public void multiply(double val) - multiply the member field by the parameter
public void divide(double val) - divide the member field by the parameter
public void clear( ) - set the member field to 0.0
public double getValue( ) - return the member field
Given two double input values num1 and num2, the program outputs the following values:
The initial value of the instance field, value
The value after adding num1
The value after multiplying by 3
The value after subtracting num2
The value after dividing by 2
The value after calling the clear() method
Ex: If the input is:
10.0 5.0
the output is:
0.0
10.0
30.0
25.0
12.5
0.0

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:00
Create a cell reference in a formula by typing in the cell name or         a. right-clicking the cell. b. clicking the cell. c. clicking the column where the cell is located. d. clicking the row where the cell is located.
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
question
Computers and Technology, 22.06.2019 19:30
When using a public computer or network, you should always
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
The qwerty keyboard is the most common layout of keys on a keyboard
Answers: 3
You know the right answer?
Calculator class In the file Calculator. java, write a class called Calculator that emulates basic f...
Questions
question
Biology, 12.12.2019 19:31
question
Mathematics, 12.12.2019 19:31