The digits 0, 1, and 8 look much the same if rotated 180 degrees on the page (turned

upside down). Also, the digit 6 looks much like a 9, and vice versa, when rotated 180
degrees on the page. A multi-digit number may also look like itself when rotated on the
page; for example 9966 and 10801 do, but 999 and 1234 do not.
You are to write a program to count how many numbers from a given interval look like
themselves when rotated 180 degrees on the page. For example, in the interval [1..100]
there are six : 1, 8, 11, 69, 88, and 96.
Your program should take as input two integers, m and n, which define the interval to be
checked, 1 ≤ m ≤ n ≤ 32000. The output from your program is the number of rotatable
numbers in the interval.
You may assume that all input is valid.
Input/output is not from/to files for this question. Keyboard input and screen output is
expected.
Sample Session User input is in italics.
Enter the lower bound of the interval:
1
Enter the upper bound of the interval:
100
The number of rotatable numbers is:
6

I am kind of stuck withe logic... help me please.

No one has answered this question yet.

See response at http://www.jiskha.com/display.cgi?id=1300048949

To solve this problem, you need to iterate through each number in the given interval, and for each number, check if it looks the same when rotated 180 degrees on the page.

Here's a step-by-step approach to implement the logic:

1. First, prompt the user to enter the lower bound of the interval.
2. Read the input and store it in a variable.
3. Prompt the user to enter the upper bound of the interval.
4. Read the input and store it in another variable.
5. Initialize a counter variable to keep track of the number of rotatable numbers found.
6. Iterate through each number in the range from the lower bound to the upper bound (inclusive).
7. For each number, convert it to a string.
8. Check if the string contains any digits other than 0, 1, 6, 8, or 9. If it does, skip to the next number.
9. Reverse the string.
10. Create a mapping for each digit: 0 maps to 0, 1 maps to 1, 6 maps to 9, 8 maps to 8, and 9 maps to 6.
11. Initialize an empty string to store the rotated number.
12. Iterate through each character in the reversed string.
13. Using the digit mapping, append the corresponding digit to the rotated number string.
14. If the rotated number string is equal to the original number string, increment the counter variable by 1.
15. After iterating through all the numbers in the interval, print the value of the counter variable as the output.

By following this logic, you should be able to count the number of rotatable numbers in the given interval.