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

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 19:30, 10040813
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
image
Engineering, 04.07.2019 18:10, viicborella
Steel is coated with a thin layer of ceramic to protect against corrosion. what do you expect to happen to the coating when the temperature of the steel is increased significantly? explain.
Answers: 1
image
Engineering, 04.07.2019 18:10, xboxdude06
Slip occurs via two partial dislocations because of (a) the shorter path of the partial dislocation lines; (b) the lower energy state through partial dislocations; (c) the charge balance.
Answers: 1
image
Engineering, 04.07.2019 18:10, Candi9697
A-mn has a cubic structure with a0 0.8931 nm and a density of 7.47 g/cm3. b-mn has a different cubic structure, with a0 0.6326 nm and a density of 7.26 g/cm3. the atomic weight of manganese is 54.938 g/mol and the atomic radius is 0.112 nm. determine the percent volume change that would occur if a-mn transforms to b-mn.
Answers: 2
You know the right answer?
Define a MathOp interface that has four methods for add, subtract, multiply, and divide. These metho...

Questions in other subjects:

Konu
Mathematics, 27.08.2019 10:10