* Input a number ranging 0-999999999.
* A variable num3 is declared global that gets the value of zero.
* Using for loop a variable i gets the value of zero, which will be less than equal to the number and is expresses increment.
* To get the reverse of the number using for loop:
a.) Get the modulo of the number by 10.
b.) Divide the number by 10.
c.) Multiply the variable num3 by 10. Add it with the result of modulo of the number.
d.) Continuing until number reaches to zero which is the end of the for loop.
* To get the result using if-else:
a.) If the the number entered is the same as the reverse result, the number is PALINDROME.
b.) If not, the number is NOT PALINDROME.
* In catching exceptions using do-while so that the program will not exit and continue until you will input the correct number:
a.) The number entered will be in letters, the running program will be interrupt and instead the program will exit, it will display INVALID INPUT. PLEASE TRY AGAIN! and you will be entering a number again.
b.) The number entered will exceed from 0-999999999, the running program will be interrupt and instead the program will exit, it will display INVALID INPUT. PLEASE TRY AGAIN! and you will be entering a number again.
Wednesday, January 13, 2010
Subscribe to:
Comments (Atom)
