ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2018 ICSE Computer Science Paper



Share with a Friend

Solved 2018 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Proper Case Program - ICSE 2018 Computer Science

Write a program in Java to accept a string in lowercase and change the first letter of every word to uppercase. Display the new string.

Sample input: we are in cyber world
Sample Output: We Are In Cyber World

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

Output

 
 OUTPUT : 
Enter the string: we are in cyber world
We Are In Cyber World