Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create JUnit test cases ( code ) in Eclipse to test the Java code given below. Write the code for test cases for each of
Create JUnit test cases code in Eclipse to test the Java code given below. Write the code for test cases for each of the following assertions to test the expected output of each method in math class.
assertEqualsmessage expectedValue, value
assertNotEqualsmessage value value
Calculator Class
package assignment;
import java.util.Scanner;
public class calculator
public static void mainString args
Scanner input new ScannerSystemin;
Math Math new MathTest;
double answer ;
double inputA, inputB;
char operator;
boolean done false;
while done false
System.out.printPlease enter your sum: ;
inputA input.nextDouble;
operator input.nextcharAt;
inputB input.nextDouble;
switch operator
case : answer Math.addinputA inputB;
break;
case : answer Math.subtractinputA inputB;
break;
case : answer Math.multiplyinputA inputB;
break;
case : answer Math.divideinputA inputB;
break;
case : answer Math.exponentinputA inputB;
break;
System.out.printlnanswer;
input.close;
package assignment;
public class doubleMath
double adddouble a double b
double answer ab;
return answer;
double subtractdouble a double b
double answer ab;
return answer;
double multiplydouble a double b
double answer ab;
return answer;
double dividedouble a double b
double answer ab;
return answer;
double powerdouble a double b
double answer a;
for int x; xb; x
answer a;
return answer;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started