subject
Engineering, 18.02.2020 00:57 hrcatena

Define a MathOp interface that has four methods for add, subtract, multiply, and divide. These methods only work with integers.
Implementation
You will write a class that implements MathOp to support arithmetic operations. Each method should have two parameters. The divide method will throw an exception if the divisor is 0.
Write a program that uses the interface and implementation to allow the users to perform some arithmetic.
Sample run (text marked as bold are user inputs):

run:
1)add, 2)sub, 3)multiply, 4) divide, 5) exit:1
Enter operands:2 4
6
1)add, 2)sub, 3)multiply, 4) divide, 5) exit:2
Enter operands:4 2
2
1)add, 2)sub, 3)multiply, 4) divide, 5) exit:3
Enter operands:2 3
6
1)add, 2)sub, 3)multiply, 4) divide, 5) exit:4
Enter operands:3 2
1
1)add, 2)sub, 3)multiply, 4) divide, 5) exit:4
Enter operands:2 1
2
1)add, 2)sub, 3)multiply, 4) divide, 5) exit:4
Enter operands:3 0
Division by zero error!
1)add, 2)sub, 3)multiply, 4) divide, 5) exit:5
Bye!

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Water at 55c flows across a flat plate whose surface temperature is held constant at 95c. if the temperature gradient at the plate's surface for a given value of x is 18 c/mm, find a) local heat transfer coefficient. b) heat flux
Answers: 3
question
Engineering, 04.07.2019 19:10
What is the main objective of using reheat rankine cycle?
Answers: 3
question
Engineering, 04.07.2019 19:10
The proportional limit is always greater than the yield strength for a material. a)-trune b)- false
Answers: 3
question
Engineering, 04.07.2019 19:10
Estimate the change in specific internal energy au and specific enthalpy h from inlet to outlet for ethylene glycol (a liquid) flowing through each of the following devices: (a) a heat exchanger where the glycol temperature increases from 20 °c to 80 °c; (b) a pump operating at about 25 °c and increasing the glycol pressure from 100 kpa to 8 mpa.
Answers: 2
You know the right answer?
Define a MathOp interface that has four methods for add, subtract, multiply, and divide. These metho...
Questions
Questions on the website: 13722363