File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
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: 39478
    
  28
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: 39478
    
  28
So what was the error?
 
wood burning stoves
 
subject: Unable to execute the program (no compilation error)