Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to add number of digit in array  RSS feed

 
vineet walia
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me out

what i want is ...

1.user enter no of digit of tat number
2.thn use enter tat number

so i want to store tat number in array..
please help me out i try some code but unable to do
>
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the final time through the loop,



always evaluates to zero

so num2 ends up being zero and this causes a division by zero error when you say

 
vineet walia
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim McGuire wrote:the final time through the loop,



always evaluates to zero

so num2 ends up being zero and this causes a division by zero error when you say



so how we can resolve this problem???
 
Janeice DelVecchio
Bartender
Posts: 1812
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could loop one less time and handle outside the loop or set an if statement inside the loop to take care of the last entry.
 
Let nothing stop you! Not even this tiny ad:
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!