Use the following problems to test your string manipulation and mathematical corner case programming prowess. I strongly encourage you to give each problem a try before you turn to the solutions and download the example programs:
- Counting duplicate characters: Write a program that counts duplicate characters from a given string.
- Finding the first non-repeated character: Write a program that returns the first non-repeated character from a given string.
- Reversing letters and words: Write a program that reverses the letters of each word and a program that reverses the letters of each word and the words themselves.
- Checking whether a string contains only digits: Write a program that checks whether the given string contains only digits.
- Counting vowels and consonants: Write a program that counts the number of vowels and consonants in a given string. Do this for the English language, which has five vowels (a, e, i, o, and u).
- Counting occurrences of a certain character: Write a program that counts the occurrences of a certain character in a given string.
- Converting String into int, long, float, or double: Write a program that converts the given String object (representing a number) into int, long, float, or double.
- Removing white spaces from a string: Write a program that removes all white spaces from the given string.
- Joining multiple strings with a delimiter: Write a program that joins the given strings by the given delimiter.
- Generating all permutations: Write a program that generates all of the permutations of a given string.
- Checking whether a string is a palindrome: Write a program that determines whether the given string is a palindrome or not.
- Removing duplicate characters: Write a program that removes the duplicate characters from the given string.
- Removing given characters: Write a program that removes the given character from the given string.
- Finding the character with the most appearances: Write a program that finds the character with the most appearances in the given string.
- Sorting an array of strings by length: Write a program that sorts by the length of the given array of strings.
- Checking that a string contains a substring: Write a program that checks whether the given string contains the given substring.
- Counting substring occurrences a string: Write a program that counts the occurrences of a given string in another given string.
- Checking whether two strings are anagrams: Write a program that checks whether two strings are anagrams. Consider that an anagram of a string is a permutation of this string by ignoring capitalization and white spaces.
- Declaring multiline strings (text blocks): Write a program that declares multiline strings or text blocks.
- Concatenating the same string n times: Write a program that concatenates the same string a given number of times.
- Removing leading and trailing spaces: Write a program that removes the leading and trailing spaces of the given string.
- Finding the longest common prefix: Write a program that finds the longest common prefix of given strings.
- Applying indentation: Write several snippets of code to apply indentation to the given text.
- Transforming strings: Write several snippets of code to transform a string into another string.
- Computing the minimum and maximum of two numbers: Write a program that returns the minimum and maximum of two numbers.
- Summing two large int/long numbers and operation overflow: Write a program that sums two large int/long numbers and throws an arithmetic exception in the case of an operation overflow.
- String as an unsigned number in the radix: Write a program that parses the given string into an unsigned number (int or long) in the given radix.
- Converting into a number by an unsigned conversion: Write a program that converts a given int number into long by an unsigned conversion.
- Comparing two unsigned numbers: Write a program that compares the given two numbers as unsigned.
- Division and modulo of unsigned values: Write a program that computes the division and modulo of the given unsigned value.
- double/float is a finite floating-point value: Write a program that determines whether the given double/float value is a finite floating-point value.
- Applying logical AND/OR/XOR to two boolean expressions: Write a program that applies the logical AND/OR/XOR to two boolean expressions.
- Converting BigInteger into a primitive type: Write a program that extracts the primitive type value from the given BigInteger.
- Converting long into int: Write a program that converts long into int.
- Computing the floor of a division and modulus: Write a program that computes the floor division and the floor modulus of the given dividend (x) and divisor (y).
- Next floating-point value: Write a program that returns the next floating-point adjacent to the given float/double value in the direction of positive and negative infinity.
- Multiplying two large int/long values and operation overflow: Write a program that multiplies two large int/long values and throws an arithmetic exception in the case of operation overflow.
- Fused Multiply Add (FMA): Write a program that takes three float/double values (a, b, c) and computes a * b + c in an efficient way.
- Compact number formatting: Write a program that formats the number 1,000,000 to 1M (US locale) and to 1 mln (Italian locale). In addition, parse 1M and 1 mln from a string into a number.