Create a function
add they take a
string and return a
string like :
String add(String number)
- The method can take 0,1 or 2 numbers separated by comma and return their sum,
- an empty string will return “0”
- Example of inputs : “”, “1”, “1.1,2.2”
Allow the add method to handle an unknow number of arguments
Allow the add method to handle new lines as separator
175.2,\n35is invalid and return the message
Number expected but '\n' found at position 6.
Missing number in last position
1,3,is invalid and return the message
Number expected but EOF found.
Allow the add method to handle a different delimiter
To change the delimiter, the beginning of the string will contain a separate line that looks like this :
//|\n1|2,3is invalid and return the message
'|' expected but ',' found at position 3.
All existing scenarios should work as before.
Calling add with negatives numbers will return the message “Negative not allowed : “ listing all negative numbers that were in the list of numbers
-1,2is invalid and return the message
Negative not allowed : -1
2,-4,-5is invalid and return the message
Negative not allowed : -4, -5
Calling add with multiple errors will return all errors message separated by new line.
-1,,2is invalid and return the message
Negative not allowed : -1\nNumber expected but ',' found at position 3.
Write a function for multiply with same rules