ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2017 ICSE Computer Science Paper



Share with a Friend

Solved 2017 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Abbreviation Program - ICSE 2017 Specimen Computer Science

Write a program to accept a sentence and print only the first letter of each word of the sentence in capital letters separated by a full stop.
Example:
INPUT: This is a cat.
OUTPUT: T.I.A.C.

import java.io.*; class Sentence{ public static void main(String args[])throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the sentence: "); String s = br.readLine(); s = s.trim(); s = s.toUpperCase(); String t = ""; for(int i = 0; i < s.length(); i++){ if(i == 0 || s.charAt(i - 1) == ' ') t += s.charAt(i) + "."; } System.out.println(t); } }

Output

 
 OUTPUT : 
Enter the sentence: This is a cat.
T.I.A.C.