Java Question : Infosys
public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); StringTokenizer st = new StringTokenizer(s, ","); int size = st.countTokens(); int[] arr = new int[size]; int c = 0; while (st.hasMoreTokens()) { arr[c] = Integer.parseInt(st.nextToken()); c++; } int sum = 0; for (int i = 0; i < size; i++) { boolean flag = false; int num = arr[i]; while (num > 0) { int lastdigit = num % 10; if (lastdigit == 6) { lastdigit = 9; flag = true; } num = num / 10; } int reverse = 0; if (flag == true) { int num1 = arr[i]; while (num1 > 0) { int lastdigit1 = num1 % 10; if (lastdigit1 == 6) { lastdigit1 = 9;