This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to add number of digit in array

 
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
Saloon Keeper
Posts: 1809
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic