Hello. I'm currently a 10th grader who's been sitting in front of the computer for hours trying to figure this assignment out. First, my teacher gave me a reverse integer problem. He wants us to reverse the numbers 12345, 10001, 1200, and 5
, and display in in the output. The leading zeros can be omitted. I got the method down here (for the first integer):
//initialize
int tmpInt1 = 0;
while(tmpInt1 == 12345)
{
newInt *= 10;
newInt += tmpInt1 % 10;
tmpInt1 /= 10;
}
However, there seems to be a problem displaying it in the output, which looks like this:
FunLoops fun = new FunLoops();
System.out.println("12345 reversed ---> " + fun.reverse(12345));
That's just the first reverse integer, and I am clueless on how to add the other numbers in. Should I use a nested loop? If so, how should I use it? After I figure this out, I still need to do the LCM and the Magic Square part, which is even more complicated. I'm glad I have a 4-day weekend, so this isn't that urgent. But I still need the help. Can someone please show me the correct way to do this? Thank you all so much!!!