163 subscribers
3.42K photos
24 videos
39 files
371 links
Link: @java_posts

Contact: java.response.email@gmail.com
Download Telegram
To reverse a number, follow the steps given below:
* First, we find the remainder of the given number by using the modulo (%) operator.
* Multiply the variable reverse by 10 and add the remainder into it.
* Divide the number by 10.
#Source_code
#60
In the following program, we have replaced the while loop by a for loop. It also removes the last digit of the number, after each iteration. When the condition, number!=0 becomes false, the loop exits and we get the reversed number.
#Source_code
#61
The following program reverses both numbers, positive and negative. When we enter a number, it first checks the number is positive or negative. If the number is negative, it converts the number into positive by multiplying -1. After that, it performs the same steps (as we have performed in the above programs) to reverse a number. At last, again it checks the number is negative or positive. To make the number negative, it again multiplies the reverse number by -1.
#Source_code
#62
NumberToWorldExample1.png
1.1 MB
In this section, we will create a Java program that converts the given number into words. For example, if the given number is 54,297 then the output should be Fifty-Four Thousand Two Hundred Ninety-Seven. Let's create a Java program for the same.
#Source_code
#64
Java
NumberToWorldExample1.png
The number is not limited to four digits. Then what if the user enters more than 5 five digits numbers. The above program does not work for large digit numbers.
#Output
#64
NumberToWorldExample2.png
1.6 MB
Converting Large Numbers into Words
The logic for converting the large digit numbers is quite different. Let's see the approach to convert large digits numbers.
#Source_code
#65
What is an automorphic number?
A number is called an automorphic number if and only if the square of the given number ends with the same number itself. For example, 25, 76 are automorphic numbers because their square is 625 and 5776, respectively and the last two digits of the square represent the number itself. Some other automorphic numbers are 5, 6, 36, 890625, etc.
#Output
#67
#68
#69