Question: Please write code in Java. Question 2: Write a program that will take two strings of same size as input. If the string is a
Please write code in Java.
Question 2: Write a program that will take two strings of same size as input. If the string is a number then it will first find out the digit sum of the corresponding position, and will return the largest digit sum. If the strings have any characters other than digit , it will return a message that "largest digit sum is not possible". [You need to use next() function of Scanner class to take string input. You can get the individual characters using charAt(i) function. You can check if a character is digit or not by using Character.isDigit() function. You can use Character.getNumericValue() function to convert a character to a string.) Explanation Sample Input & Output: 2 Stringi 1 3 1 5 Enter the first string 3 String2 2 2 12323123102195 Sum 3 7 9 7 8 5 9 16 7 Enter the second string The largest Sum is 16 25674324683872 The larges digit sum is 16 3 1 2 3 2 7 1 6 0 8 2 3 9 7 5 6 8 2 9 7 4 4 7 Sample Input & Output: Enter the first string 2adg3345 Enter the second string 12345678 largest digit sum is not possible 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
