Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java Please. Also, clearly explain your code. Thanks. Name the files TestCalculate and Calculator String Calculator 1. Create a simple String calculator with a

In Java Please. Also, clearly explain your code. Thanks.

Name the files TestCalculate and Calculator

String Calculator 1. Create a simple String calculator with a method: int Add(string numbers) a. The numbers in the string are separated by a comma. b. Empty strings should return 0. c. The return type should be an integer. d. Example input: 1,2,5 - expected result: 8. e. Write tests to prove your input validates. 2. Change the Add method to handle new lines in the input format a. Example: 1 ,2,3 - Result: 6 3. Support a custom delimiter a. The beginning of your string will now contain a small control code that lets you set a custom delimiter. b. Format: //[delimiter] [delimiter separated numbers] c. Example: //; 1;3;4 - Result: 7 d. In the above you can see that following the double forward slash we set a semicolon, followed by a new line. We then use that delimiter to split our numbers. e. Other examples i. //$ 1$2$3 - Result: 6 ii. //@ 2@3@8 - Result: 13 4. Calling add with a negative number should throw an exception: Negatives not allowed. The exception should list the number(s) that caused the exception Bonus 1. Numbers larger than 1000 should be ignored. a. Example 2,1001 - Result: 2 2. Delimiters can be arbitrary length a. //*** 1***2***3 - Result 6 3. Allow for multiple delimiters a. //$,@ 1$2@3 - Result 6 4. Combine 2 and 3 bonus questions. Allow multiple delimiters of arbitrary length

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 Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

The links between existential psychology and positive psychology.

Answered: 1 week ago