Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Unable to execute the program (no compilation error) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Unable to execute the program (no compilation error)" Watch "Unable to execute the program (no compilation error)" New topic
Author

Unable to execute the program (no compilation error)

Alexie Chong
Greenhorn

Joined: Sep 16, 2011
Posts: 3
Dear experts,

I am doing my assignment on finding how many numbers in N digit satisfy K requirement.
However, when i am testing the code, i could compile it but i couldn't execute it.
I am wondering if i made mistake in the as when i comment this out, my program is able to execute,though i didn't get the right output value
Please kindly enlighten me.

Logic of my codes (example):

N = 15, K = 3

When N = 1, result = 0 + (N%10)
= 0 + (1%10)
= 1

y = N/10
= 1/10
= 0

x = 1 + 0
= 1
return x = 1

if (sumOfDigits(1) == K)
noOfNoSatisfy ++;
----------------------------------------------------
In the case of above, noOfSatisfy still remains as 0
-----------------------------------------------------
When N = 12, result = 0 + (N%10)
= 0 + (12%10)
= 2

y = N/10
= 12/10
= 1

x = 1 + 2
= 3
return x = 3

if (sumOfDigits(3) == K)
noOfNoSatisfy ++;

----------------------------------------------------
In the case of above, noOfSatisfy increase and plus 1
-----------------------------------------------------

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Welcome to the Ranch

What goes wrong when you try that code? You have to tell us the full details, otherwise we can't help.
Alexie Chong
Greenhorn

Joined: Sep 16, 2011
Posts: 3
I used to have issue in getting the desired output which i want. Then i realized i made a mistake with the algorithim and have worked it out just fine.
Thanks so much for helping anyway
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
So what was the error?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to execute the program (no compilation error)
 
Similar Threads
how to calculate the N to the power of N
Digits in Array
LinkedList insert, remove and change
Question on widening ,boxing
Java Code