ICSE Java String Programs for Class 10
ICSE Java String Programs for Class 10
The program transforms input strings into Pig Latin by first converting all characters to uppercase. It then identifies the first vowel to determine the split point and appends the leading consonants to the end followed by 'AY'. For example, 'Trash' becomes 'ASHTRAY' as it moves the initial consonants 'TR' after the rest of the word and adds 'AY' .
The pattern transformation program examines given strings by iterating and printing substrings in either ascending or descending order. This approach formats visual patterns slightly differently, depending on iteration logic, which can facilitate understanding of string characters and pattern perception .
The program transforms sentences into initials by trimming whitespace, adding a space at the start, and iterating through each character. It detects spaces to identify the initials and appends the uppercase next character followed by a period. This method can be useful for creating acronyms or simplifying lengthy titles into more readable forms .
The program converts the input word to lowercase, then iteratively replaces each vowel with its ASCII successor using character manipulation. This transformation modifies the sound of the word significantly and could be leveraged for coding or playful cryptographic techniques .
The program computes the 'worth' of a word by summing the positions of each letter in the English alphabet. For uppercase letters, it subtracts 64 from the ASCII value, which aligns 'A' with 1, 'B' with 2, etc. For lowercase letters, it subtracts 96, aligning similarly. This method uses ASCII values to effortlessly map characters to their respective positions .
The program iterates through the input string while checking each character against the next one. If it finds two consecutive identical characters, it increments a counter. This double letter identification is valuable for text analysis, such as detecting misspellings or analyzing linguistic patterns .
The program captures the first character of each name segment as an initial by finding spaces between segments. First, it outputs the first letter of the entire string, then uses indices to locate spaces, capturing subsequent initials. This approach succinctly represents full names as initials, useful for formal communications where brevity is valued .
The program iterates through the string, checks each character, and forms a new string by excluding vowels. This vowel removal technique can be used in data compression or generating unique identifiers that omit common letter usage for readability .
The program replaces specific words and numbers in a string using the replace function. Such a substitution is practical for updating standard templates, such as altering event dates or modifying thematic content quickly without complete rewrites .
The program uses substring manipulation to interchange surnames. It first identifies the index of the space character separating the first and last names in each input string. Then, it combines the first name with the swapped surname using substring concatenation. The output results in the first name from the first input being combined with the surname from the second input, and vice versa .