ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2020 ICSE Computer Science Paper



Share with a Friend

Solved 2020 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

UpperCase Conversion Program - ICSE 2020 Computer Science

Question 6
Write a program to input a sentence and convert it into uppercase and display each word in a separate line.
Example:
Input: India is my country
Output:
INDIA
IS
MY
COUNTRY

import java.util.Scanner; class Display{ public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.print("Enter the sentence: "); String s = in.nextLine().toUpperCase(); String w = ""; for(int i = 0; i < s.length(); i++){ char ch = s.charAt(i); if(Character.isLetterOrDigit(ch)) w += ch; else{ System.out.println(w); w = ""; } } } }

Output

 
 OUTPUT : 
Enter the sentence: India is my country.
INDIA
IS
MY
COUNTRY