Mission:
Create a program that creates a secret code for a user inputted number.
Details
Write a program that asks a user to input a number. Come up with a specific method to encode the number by altering each numeral in the number by a certain value. The new code must be the same number of digits as the original number.
For instance, your encoding method might be the following:
if the numeral is less than or equal to 3, triple it
else if the numeral is less than or equal to 7, increase it by 2
else divide it in half
Hint: You know how to get specific characters in a string. By storing each character in an array and converting them to integers, you can do math on them!
Example Program (uses the above example method of encoding)
What is your number? 340259
Your secret code is: 960674
No comments:
Post a Comment