ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2013 ICSE Computer Science Paper



Share with a Friend

Solved 2013 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Piglatin Program - ICSE 2013 Computer Science

Write a program that encodes a word into Piglatin. To translate word into Piglatin word, convert the word into uppercase and then place the first vowel of the original word as the start of the new word along with the remaining alphabets. The alphabets present before the vowel being shifted towards the end followed by “AY”.
Sample Input 1: London
Output: ONDONLAY
Sample Input 2: Olympics
Output: OLYMPICSAY

import java.util.Scanner; class Piglatin{ public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.print("Enter the word: "); String w = in.next().toUpperCase(); int i; for(i = 0; i < w.length(); i++){ char ch = w.charAt(i); if("AEIOU".indexOf(ch) >= 0) break; } String p = w.substring(i) + w.substring(0, i) + "AY"; System.out.println(p); } }

Output

 
 OUTPUT 1: 
Enter the word: London
ONDONLAY

 OUTPUT 2: 
Enter the word: Olympics
OLYMPICSAY