Write a java program to find the sum of the odd digit in a string.

Write a program to input a string array. The input may contain digits and alphabets (“de5g4G7R”). Extract odd digits from each string and find the sum and print the output. For example, if the string is “AKj375A” then take 3+7+5=15 and not as 375 as the digit. Assume the maximum length of the array is …

Write a java program to find the sum of the odd digit in a string. Read More »

Write a java program to shrink a name.

Write a program that accepts a string as input and converts the first two names into dot-separated initials and prints the output. The input string format is ‘fn mn ln’.   The output string format is ‘ln [mn’s 1st character].[fn’s 1st character]’ Input and Output Format Input consists of a string. The output consists of a …

Write a java program to shrink a name. Read More »

Write a Java program to find unique characters in a String

Write a program that takes a string and returns the number of unique characters in the string. If the given string does not contain any unique characters return 0. The return type of the output is the count of all unique characters in the strings. Input and Output Format Input consists of a string. The …

Write a Java program to find unique characters in a String Read More »

Write a java program to find length of the largest Chunk in a string

Write a program to read a string and find the length of the largest chunk in the string. If there is no chunk print “No chunks” else print the length. NOTE: chunk is the letter which is repeating 2 or more than 2 times. The return type (Integer) should return the length of the largest chunk …

Write a java program to find length of the largest Chunk in a string Read More »

Write a java program to Count Sequential Characters.

Write Java code to count the number of characters that get repeated 3 times consecutively and return that count (ignore case). Get a string as input. If no character gets repeated 3 times consecutively return -1. The return type of the output is the repeat count. Input and Output Format Input consists of a string. …

Write a java program to Count Sequential Characters. Read More »

Write a java program to find average of elements in Hashmap.

Write code to find out the average of all values whose keys are even numbers. Round the average to two decimal places and return as output. [Hint: If the average is 5.901, the rounded average value is 5.9. The average is 6.333, the rounded average value is 6.33. ] The return type of the output …

Write a java program to find average of elements in Hashmap. Read More »

Write a java program to remove a character from a string.

Write a program to input a string and a character, and remove that character from the given String. Print the final string. Input and Output Format Input consists of a string and a character. The output consists of a string(the character cleaned string). Refer sample output for formatting specifications Sample Input : elephant e Sample …

Write a java program to remove a character from a string. Read More »

Write a java program to modify a string.

Write a program to input a person’s name in the format “FirstName LastName” and return the person’s name in the following format – “LastName, InitialOfFirstName”. Input and Output Format Input consists of a string that corresponds to a Person’s name. Output consists of a string(person’s name in expected format). Refer sample output for formatting specifications …

Write a java program to modify a string. Read More »