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
Refrigerant 134a enters an insulated compressor operating at steady state as saturated vapor at -26°c with a volumetric flow rate of 0.18 m3/s. refrigerant exits at 9 bar, 70°c. changes in kinetic and potential energy from inlet to exit can be ignored. determine the volumetric flow rate at the exit, in m3/s, and the compressor power, in kw.
Answers: 1
question
Engineering, 04.07.2019 18:10
Aflywheel accelerates for 5 seconds at 2 rad/s2 from a speed of 20 rpm. determine the total number of revolutions of the flywheel during the period of its acceleration. a.5.65 b.8.43 c. 723 d.6.86
Answers: 2
question
Engineering, 06.07.2019 04:20
At what temperature does the mole fraction of no reach 0.010 for the equilibrium products resulting from the combustion of gasoline and air at 1.0 and 5000 kpa?
Answers: 1
question
Engineering, 06.07.2019 04:30
List five instruments for angular measurement and explain one of them witlh appropriate diagram(s)
Answers: 1
You know the right answer?
Define a MathOp interface that has four methods for add, subtract, multiply, and divide. These metho...
Questions
question
History, 02.04.2020 19:42
question
Biology, 02.04.2020 19:42
Questions on the website: 13722362