Set up a new project in your IDE with a Main class. In your Main class, creatte
Question:
Set up a new project in your IDE with a Main class. In your Main class, creatte a nextHappyNummethod.
int nextHappyNum(int num)
1. For a given non-negative integer N, find the next smallest Happy Number. A number is called happy if it leads to 1 after a sequence of steps where in each step number is replaced by sum of squares of its digits. That is if we start with Happy Number and keep replacing it with digits square sum, we reach 1 (7 -> 49 -> 97 -> 130 -> 10 -> 1). For example,
----------------------------------
Input: 8 Output: 10 Input: 3 Output: 7 Input: 0 Output: 1 Input: 10 Output: 13
----------------------------------
2. In your Main class, creatte a decodeString method.
String decodeString(String s)
An encoded string (s) is given, the task is to decode it. The pattern in which the strings were encoded were as follows original string:abbbababbbababbbab encoded string :"3[a3[b]1[ab]]".
For example:
----------------------------------
Input: 1[b] Output: b Input: 3[b2[ca]1[d]] Output: bcacadbcacadbcacad
----------------------------------
Cost Management Measuring Monitoring And Motivating Performance
ISBN: 9781118168875
2nd Canadian Edition
Authors: Leslie G. Eldenburg, Susan Wolcott, Liang Hsuan Chen, Gail Cook