Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the class Calculation below. It has 3 static methods findMax, cube, and reverseWords. Also provided is the test class TestCalculation which has all the

Consider the class Calculation below. It has 3 static methods findMax, cube, and reverseWords. Also provided is the test class TestCalculation which has all the library imports and some of the methods predefined. Add test methods that test all static methods of Calculation class. For findMax method, ensure that you test for both positive and negative integers. You can assume that all necessary imports are already provided. public class Calculation { //method that returns maximum number public static int findMax(int arr[]) { int max=0; for (int i=1;inn; } //method that returns reverse words. E.g., "hello world" is returned as "olleh dlrow" public static String reverseWord(String str) { StringBuilder result=new StringBuilder(); StringTokenizer tokenizer=new StringTokenizer(str," "); while (tokenizer.hasMoreTokens()) { StringBuilder sb=new StringBuilder(); sb.append(tokenizer.nextToken()); sb.reverse(); result.append(sb); result.append(" "); } return result.toString(); } } import static org.junit.Assert.assertEquals; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.javatpoint.logic.Calculation; public class TestCalculation { @BeforeClass public static void setUpBeforeClass() throws Exception { System.out.println("before class"); } @Before public void setUp() throws Exception { System.out.println("before"); } @After public void tearDown() throws Exception { System.out.println("after"); } @AfterClass public static void tearDownAfterClass() throws Exception { System.out.println("after class"); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

Classify delivery styles by type.

Answered: 1 week ago

Question

Consider this article:...

Answered: 1 week ago