Hi another exercise which im having problems with. In this challenge im given a four digit integer and encrypt each digit as follows. Replace each digit by the sum of that digit plus seven mod 10. Then swap 1st and 3rd digit places and 2nd with 4th. Heres what i got so far. I havent figured out yet how to swap them. Any thoughts on that ? No arrays allowed.
Personally, rather than go through a lot of if/else do/while statements, I'd just split
the original number into its four constituent digits (call them ones, tens, hundreds,
thousands), perform the + 7 % 10 on each digit, then reform the new number.
It means duplicating the + 7 % 10 line of code four times, but all in all, your
program will be all of about 12 lines of code then instead of 50.
I dont know why i over complicate things. Thanks its just that this chapter is dealing with loops and if else statements and im automatically think that authors intentions was to use loops.