Wednesday , 22 May 2019
Home » Class 12 » ISC 2013 [Question 3] Practical Paper Solved

ISC 2013 [Question 3] Practical Paper Solved

Question:

Palindrome is a word that may be read the same way in either direction.

Accept a sentence in UPPER CASE which is terminated by either ” . “, ” ? ” or ” ! “.

Each word of the sentence is separated by a single blank space.

Perform the following tasks:

(a) Display the count of palindromic words in the sentence.
(b) Display the Palindromic words in the sentence.

Example of palindromic words: MADAM, ARORA, NOON

Test your program with the sample data and some random data:

Example 1

INPUT : MOM AND DAD ARE COMING AT NOON.

OUTPUT : MOM DAD NOON
NUMBER OF PALINDROMIC WORDS : 3

Example 2

INPUT : NITIN ARORA USES LIRIL SOAP.

OUTPUT : NITIN ARORA LIRIL
NUMBER OF PALINDROMIC WORDS : 3

Example 3

INPUT : HOW ARE YOU?

OUTPUT : NO PALINDROMIC WORDS

Programming Code:

/**
* The class Palin_ISC2013 inputs a sentence and prints all the Palindromic words in it
* along with it’s frequency
* @author : www.javaforschool.com
* @Program Type : BlueJ Program – Java
* @Question Year : ISC Practical 2013 Question 3
*/

import java.io.*;
import java.util.*;
class Palin_ISC2013
{
static BufferedReader br=new BufferedReader (new InputStreamReader (System.in));

boolean isPalin(String s)
{
int l=s.length();
String rev=””;
for(int i=l-1; i>=0; i–)
{
rev=rev+s.charAt(i);
}
if(rev.equals(s))
return true;
else
return
false;
}

public static void main(String args[])throws IOException
{
Palin_ISC2013 ob=new Palin_ISC2013();
System.out.print(“Enter any sentence : “);
String s=br.readLine();
s=s.toUpperCase();

StringTokenizer str = new StringTokenizer(s,”.?! “);
int w=str.countTokens();

String word[]=new String[w];
for(int i=0;i

Output:

1. Enter any sentence : MOM AND DAD ARE COMING AT NOON.
OUTPUT : MOM DAD NOON
Number of Palindromic Words : 3

2. Enter any sentence : HOW ARE YOU?
OUTPUT : No Palindrome Words

Check Also

Infix Postfix Prefix Conversion – Correct Method (ISC Computer Science)

In this video we discuss about the correct way of converting an Infix Expression to Postfix and Prefix.

Leave a Reply

Your email address will not be published. Required fields are marked *