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
Asingle-geared blanking press has a stroke of 200 mm and a rated capacity of 320 kn. a cam driven ram is assumed to be capable of delivering the full press load at constant force during the last 15 percent of a constant-velocity stroke. the camshaft has an average speed of 90 rev/min and is geared to the flywheel shaft at a 6: 1 ratio. the total work done is to include an allowance of 16 percent for friction a) estimate the maximum energy fluctuation b) find the rim weight for an effective diameter of 1.2 m and a coefficient of speed fluctuation of 0.10
Answers: 1
question
Engineering, 04.07.2019 18:10
True or false (explain) (110)[111] is a slip system in bcc metals . the {111} family in fcc contains 8 planes. resolved shear stress (rss) in single crystals is just related to the applied stress. critical resolved shear stress (crss) in single crystal metals is direct proportional to the number of defects in the structure
Answers: 2
question
Engineering, 04.07.2019 18:20
What is the heat treatment of metals? what is the benefit of it? why and how it's useful? answer in details, do not write by hand.
Answers: 3
question
Engineering, 04.07.2019 19:10
An engine, weighing 3000 n, is supported on a pedestal mount. it has been observed that the engine induces vibration into the surrounding area through its pedestal at the maximum operating speed. determine the stiffness of the dynamic vibration absorber spring in (n/m) that will reduce the vibration when mounted on the pedestal. the magnitude of the exciting force is 250 n, and the amplitude of motion of the auxiliary mass is to be limited to 2 mm note: in this question type-in right numbers, no decimals, no fractions, no unit. approximate to right number if needed
Answers: 3
You know the right answer?
Define a MathOp interface that has four methods for add, subtract, multiply, and divide. These metho...
Questions
question
History, 12.07.2019 16:00
question
Mathematics, 12.07.2019 16:00