# Category: Problem Solving

## Write a java program to create math calculator.

Write a program that accepts three inputs, first two inputs are operands in int form and the third one being one of the following five operators: +, -, *, /, %. Implement calculator logic and return the result of the given inputs as per the operator provided. In case of division, Assume the result would

## Write a java program to convert a string in negative string

Given a string input, write a program to replace every appearance of the word “is” by “is not”. If the word “is” is immediately preceded or followed by a letter no change should be made to the string. Input and Output Format: Input consists of a String. The output consists of a String. Sample Input

## Write a java program to find number of days in a month

Given two inputs year and month (Month is coded as Jan=0, Feb=1, Mar=2 …), write a program to find out the total number of days in the given month for the given year. The first argument corresponds to the year and the second argument corresponds to the month code. The method returns an integer corresponding

## Write a java program to find a substring in string

Given three strings say Searchstring, Str1 and Str2 as input, write a program to find out if Str2 comes after Str1 in the Searchstring. The 3 arguments correspond to SearchString, Str1 and Str2. The function returns 1 if Str2 appears after Str1 in the Searchtring. Else it returns 2. Input and Output Format: Input consists

## Write a java program to Reverse SubString

Given a string, startIndex and length, write a program to extract the substring from right to left. Assume the last character has index 0. The 1st argument corresponds to the string, the second argument corresponds to the startIndex and the third argument corresponds to the length. Input and Output Format: The first line of the input

## Write a java program to Count Vowels in a string.

Given a string input, write a program to find the total number of vowels in the given string. returns an int that corresponds to the total number of vowels in the given string. Input and Output Format: Input consists of a string. The output consists of an integer. Sample Input: aei Sample Output: 3 Count

## Write a java program to check Date Validation

Write a program to read a string representing a date. The date can be in any of the three formats 1:dd-MM-yyyy 2: dd/MM/yyyy 3: dd.MM.yyyy If the date is valid, print valid else print invalid. The return type (integer) should be based on the validity of the date. Input and Output Format: Input consists of a string. The

## Write a java program for Simple String Manipulation.

Write a program to read a string and return a modified string based on the following rules. Return the String without the first 2 chars except when keep the first char if it is ‘j’ keep the second char if it is ‘b’. The return type (string) should be the modified string based on the

## Write a java program to find sum of common element in array.

Write a program to read two integer arrays and find the sum of common elements in both the arrays. If there are no common elements return -1 as output. The return type (integer) should be the sum of common elements. Assume that all the elements will be distinct. Input and Output Format: Input consists of

## Write a java program to find average of prime locations.

Write a program to read an integer array and find the average of the numbers located on the Prime location(indexes). Round the average to two decimal places. Assume that the array starts with index 0. The return type (double) should be the average Input and Output Format: Input consists of n+1 integers. The first integer