Question: solve in java. 1 import java.io.BufferedReader; 2 import java.io. IOException; Challenge Test Case Output 3 import java.io. InputStreamReader; 4 import java.nio.charset.StandardCharsets; Programming Challenge Description Credits:


solve in java.
1 import java.io.BufferedReader; 2 import java.io. IOException; Challenge Test Case Output 3 import java.io. InputStreamReader; 4 import java.nio.charset.StandardCharsets; Programming Challenge Description Credits: Programming Challenges by Steven S. Skiena and Miguel A Revilla 6 public class Main 8 Iterate through each line of input The problem is as follows: choose a number, reverse its digits and add it to the original. If the sum has any duplicate digits, repeat this procedure. eg. 10 public static void main(String args) throws IOException f InputStreamReader reader new InputStreamReader(System.in, StandardCharsets.UTF_8); BufferedReader in new BufferedReader(reader); String line; while ((line = in. readLine()) != null) { 12 13 122 (initial number) + 221 (reverse of initial number) 343 343+343 686 686 + 686 = 1372 (no duplicate digits) System.out.println(line); 15 16 17 18 19 In this particular case the first sum with no duplicate digits, 1372, appeared after the 3rd addition. Input: Your program should read lines of text from standard input. Each line will contain an integer n Output: For each line of input, generate a line of output which is the number of iterations (additions) to compute the first sum with no duplicate digits and that sum. They should be on one line and separated by a single space character Test 1 Test Input 122
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
