Click here to Skip to main content
15,902,447 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys,
There is a problem about java i need to solve. The user provides a string which has numbers in it. One of the numbers is missing. The first and the last number can be between -9999 and 9999 and the difference can be between -99 and 99. My program should print the missing number.
Here are some examples:

510152030
25

567566565564563562561560559557556555554
558

828588919497100103106112115118121
109

-45-35-25-55152535455565
-15

I only have a basic knowledge in java.( while,for,if)
I don't want to use break,continue,switch

I would appreciate your help...

What I have tried:

I could not try anything because my code gets too long.
Posted
Updated 11-Feb-19 5:22am
Comments
OriginalGriff 11-Feb-19 11:15am    
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Member 14048022 11-Feb-19 11:26am    
Hello,
My problem is that i can't find a starting point.
Thank you for your response.
Richard MacCutchan 11-Feb-19 11:53am    
The starting point is to decide how you can identify the missing number. From your examples above it is not obvious.

1 solution

Google[^] is your friend!

First result: Find the Missing Number - GeeksforGeeks[^]

[EDIT]
For missing numbers in string, check this: Find the missing number in a string of numbers with no separator - GeeksforGeeks[^]
 
Share this answer
 
v2
Comments
Member 14048022 11-Feb-19 11:27am    
Hello,
There are no arrays in my question. However, thank you for responding.
CPallini 11-Feb-19 15:46pm    
5.
Maciej Los 11-Feb-19 16:21pm    
Thank you, Carlo.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900