Question: This assignment will help the user understand interface implementation as a crucial software engineering component. You will implement the given interface in JAVA. This assignment
This assignment will help the user understand interface implementation as a crucial software engineering component.
You will implement the given interface in JAVA.
This assignment requires you to write the MathMethods.java class which implements the MathOperations.java interface shown below. After you have written the code for the MathMethods.java program, you will then test your code with the UsingMath.java code that is provided at the end of the page. The expected results are also printed at the bottom of the page.
Each method needs to be properly implemented.
abstract interface MathOperations{ /** * This method will receive two double numbers as a parameters * it will add them. * @param double d1, first number to add * @param double d2, second number to add * @return double, the addition of d1 + d2 */ abstract double add(double dNum1, double dNum2 ); /** * This method will receive a double number as a parameter * it will calculate its absolute value * @param double d1Num * @return double an absolute value */ abstract double absoluteValue (double dNum ); /** * This method will receive an int number as a parameter * it will determine if the number is even * @param int iNum * @return boolean true if the number is even, false otherwise */ abstract boolean isEven(int iNum); } //ends class Here is the program that uses the class that you will create. Use it to test your code.
public class UsingMath{ public static void main(String arg[ ]){ double d1 = 8.5; double d2 = -27.12; int i1=27; int i2=8; MathMethods mm = new MathMethods( ); System.out.println(mm.add(d1,d2)); System.out.println(mm.absoluteValue(d2)); System.out.println(mm.isEven(i1)); System.out.println(mm.isEven(i2)); } } Your output when running this program should be:
-18.62 27.12 false true
hint: The header for your implementation should be: public class MathMethods implements MathOperations
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
