aspose file tools*
The moose likes Beginning Java and the fly likes Automorphic Number Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Automorphic Number Problem" Watch "Automorphic Number Problem" New topic
Author

Automorphic Number Problem

Ranajoy Saha
Greenhorn

Joined: Jan 17, 2013
Posts: 15


I have created this program which checks a number is Automorphic or not. Automorphic numbers are the numbers whose square ends with the number itself or you can say it is a number whose square ends with the given integer. Eg. Square of 5 is 25 As 25 has the last digit 5 so 5 is an automorphic number. This porgram is always giving me "The number is a automorphic number." no matter whatever number I try. I cant detect the problem in this program. Please help!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18139
    
  39

Ranajoy Saha wrote:

I have created this program which checks a number is Automorphic or not. Automorphic numbers are the numbers whose square ends with the number itself or you can say it is a number whose square ends with the given integer. Eg. Square of 5 is 25 As 25 has the last digit 5 so 5 is an automorphic number. This porgram is always giving me "The number is a automorphic number." no matter whatever number I try. I cant detect the problem in this program. Please help!



If you follow the code, how often is the check variable set? And what is it set to? ... Interestingly, this value is the same regardless of what number the user enters.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ranajoy Saha
Greenhorn

Joined: Jan 17, 2013
Posts: 15
Ok, Henry Thanks for helping! Previously the check variable was initialized with 0 as num then was 0 and there was no change at all. But now I first initialized the check variable to 0 and then after the user has entered some input then it get's initialized by num.
But still the output is the same as before!
Ranajoy Saha
Greenhorn

Joined: Jan 17, 2013
Posts: 15
Thanks for the help Henry Wong! Thank you very much! I corrected my mistake!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Automorphic Number Problem
 
Similar Threads
Do while error, I'm going crazy
Displaying output for the given format
Unique Random Number Generator : Please suggest improvements to this code
diamond pattern without parse.int (Someone help me T.T) :cry:
How to combine two arrays within a loop?