Forums Register Login

Mobile number problem

+Pie Number of slices to send: Send
Hello I'm unable to execute a problem please help me out with this
Problem statement : Person x has mobile number with '-' separations in different countries.  Consider this mobile number as input and produce output in the following manner i.e, for every 3 digits '-' should be added.
Input format : 75-25-85-641852-352
Output format: 752-585-648-523-52
Please help me with this..  Thanks in advancr
+Pie Number of slices to send: Send
Welcome to CodeRanch!  What so far have you tried? Please post you code (Use code tag to post code) although it has error or doesn't produce expected result, so we can see where you went wrong.
+Pie Number of slices to send: Send
 

Savitha Gollamudi wrote:Input format : 75-25-85-641852-352
Output format: 752-585-648-523-52

I think you meant
Input: 75-25-85-641852-352
Output: 752-585-641-852-352  
What output do you expect if input has no of digits not completely divisible by 3
Example:
Input: 75-25-85-64185-23
Output: What do you expect?
+Pie Number of slices to send: Send
Your first task should be to develop the algorithm, try it out by hand on a test case, and only then should you start writing code.
One such algorithm would be to simply remove all dashes, then reparse the result to achieve the desired answer.
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 285 times.
Similar Threads
Apache Excel api
how to code this?
Problem
Program Problem
String manipulation. Help needed. ..!!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:47:44.