ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2025 ICSE Computer Science Paper



Share with a Friend

Solved 2025 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

String to Uppercase Program - ICSE 2025 Computer Science

Question 5


Define a class to accept a string and convert the same to uppercase. Create and display the new string by replacing each vowel by immediate next character and every consonant by the previous character. The other characters remain the same.


Example:
Input: #IMAGINATION@2024
Output: #JLBFJMBSJPM@2024

import java.util.Scanner; class Change{ public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.print("Enter the string: "); String s = in.nextLine().toUpperCase(); String t = ""; for(int i = 0; i < s.length(); i++){ char ch = s.charAt(i); if(Character.isLetter(ch)){ if("AEIOU".indexOf(ch) >= 0) t += (char)(ch + 1); else t += (char)(ch - 1); } else t += ch; } System.out.println(t); } }

Output

 
OUTPUT 1:
Enter the string: #IMAGINATION@2024
#JLBFJMBSJPM@2024

OUTPUT 2:
Enter the string: THIS IS A JAVA PROGRAM
SGJR JR B IBUB OQPFQBL