Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a new Java project called 1410_Recursion. Add a package recursion and a class Recursion. Include the following three static methods described below. However, don't

Create a new Java project called 1410_Recursion. Add a package recursion and a class Recursion. Include the following three static methods described below. However, don't implement them right away. Instead, start by returning the default value followed by a // TODO comment.

  1. public static int sumOfDigits(int n) This method returns the sum of all the digits. sumOfDigits(-34) -> 7 sumOfDigits(1038) -> 12
  2. public static int countSmiles(char[] letters, int index) This method counts the number of colons followed by a closing parenthesis. countSmiles([:,), ,L,i,f,e, ,i,s, ,g,o,o,d, ,:,)], 0) -> 2 countSmiles([H,a,p,p,y, ,D,a,y, ,:,),:,),:,),!], 0) -> 3 countSmiles([a,:,b,(,c,),:, ,),e], 0) -> 0
  3. public static String toUpper(String str) This method separates all characters by a space and changes all lowercase letters to uppercase letters. E.g. "Hi there!" returns "H I T H E R E !" Hint: Class Character (Links to an external site.) includes a method toUpperCase (Links to an external site.)

Create a second source folder called test. It should include a class RecursionTest. That's where you will write the JUnit tests for the three methods above.

  • Each of the three methods should have at least eight corresponding JUnit tests.
  • Choose test data deliberately to provide thorough testing that covers as many potential problems as possible.

Once you have written the JUnit tests, implement the methods.

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 And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

=+22.13. Suppose that of is a semiring containing 2.

Answered: 1 week ago