Navbar

Saturday, 20 April 2019

ISC Computer Practical Paper – 2011

ISC Computer Practical Paper – 2011

Question  1.

Write a program to input a natural number less than 1000 and display it in words.
Test your program for the given sample data and some random data.
Sample Data:
Input: 29
Output: TWENTY NINE
Input: 17001
Output: OUT OF RANGE
Input: 119
Output: ONE HUNDRED AND NINETEEN
Input:500
Output: FIVE HUNDRED

SOLUTION:

import java.io.*;
public class num
{
    //Declaring Instance variables
    int n;
    //Method to take input
    void inputNumber() throws IOException
    {
        BufferedReader inp=new BufferedReader(new InputStreamReader(System.in));
        System.out.println(“\nINPUT:\t”);
        n=Integer.parseInt(inp.readLine());
    }
    //Method to Extract digits , call other methods and display output
    public void extract()
    {
        String str=””,str1=””,str2=””;
        int hund=0,tens=0,units=0,i=0;
        if(n<1 || n>999)
            System.out.println(“\nOUT OF RANGE “);
        else
        {
            while(n!=0)
            {
                if(i==0)
                    units=n%10;
                else if(i==1)
                    tens=n%10;
                else if(i==2)
                    hund=n%10;
                i++;
                n=n/10;
            }
           if(hund>0)
                str=word1(hund)+ ” HUNDRED “;
            if(tens>1)
                str1= word2(tens);
            if(tens==1)
                str2= word3(units);
            else
                str2=word1(units);
            if((!str.equals(“”))&&(!str1.equals(“”) || !str2.equals(“”)))
                str=str+ “AND “;
            if(!str1.equals(“”))
                str=str+ str1+ ” “;
            if(!str2.equals(“”))
                str=str+ str2;
            System.out.println(“OUTPUT:\t”+str);
        }//EndElse
    }
    //Method to convert digits 0-9
    String word1(int x)
    {
        String s=””;
        switch(x)
        {
            case 1:
            s=”ONE”;
            break;
            case 2:
            s=”TWO”;
            break;
            case 3:
            s=”THREE”;
            break;
            case 4:
            s=”FOUR”;
            break;
            case 5:
            s=”FIVE”;
            break;
            case 6:
            s=”SIX”;
            break;
            case 7:
            s=”SEVEN”;
            break;
            case 8:
            s=”EIGHT”;
            break;
            case 9:
            s=”NINE”;
            break;
        }
        return s;
    }
    //Method to convert numbers 20, 30,40,…..90
    String word2(int x)
    {
        String s=””;
        switch(x)
        {
            case 2:
            s=”TWENTY”;
            break;
            case 3:
            s=”THIRTY”;
            break;
            case 4:
            s=”FOURTY”;
            break;
            case 5:
            s=”FIFTY”;
            break;
            case 6:
            s=”SIXTY”;
            break;
            case 7:
            s=”SEVENTY”;
            break;
            case 8:
            s=”EIGHTY”;
            break;
            case 9:
            s=”NINETY”;
            break;
        }
        return s;
    }
    //Method to convert numbers 10 – 19
    String word3(int x)
    {
        String s=””;
        switch(x)
        {
            case 0:
            s=”TEN”;
            break;
            case 1:
            s=”ELEVEN”;
            break;
            case 2:
            s=”TWELVE”;
            break;
            case 3:
            s=”THIRTEEN”;
            break;
            case 4:
            s=”FOURTEEN”;
            break;
            case 5:
            s=”FIFTEEN”;
            break;
            case 6:
            s=”SIXTEEN”;
            break;
            case 7:
            s=”SEVENTEEN”;
            break;
            case 8:
            s=”EIGHTEN”;
            break;
            case 9:
            s=”NINETEEN”;
            break;
        }
        return s;
    }
//    Main method to call other methods
public static void main(String args[]) throws IOException
    {
        num obj=new num
        obj.inputNumber();
        obj.extract();
    }
}
-----------------END--------------------

Question 2.

Encryption is a technique of coding messages to maintain their secrecy. A String array of size ‘n’ where ‘n’ is greater than 1 and less than 10, stores single sentences (each sentence ends with a full stop) in each row of the array.
Write a program to accept the size of the array. Display an appropriate message if the size is not satisfying the given condition. Define a string array of the inputted size and fill it with sentences row-wise. Change the sentence of the odd rows with an encryption of two characters ahead of the original character. Also change the sentence of the even rows by storing the sentence in reverse order. Display the encrypted sentences as per the sample data given below.
Test your program on the sample data and some random data.
Sample Data:
Input: n=4
IT IS CLOUDY.
IT MAY RAIN.
THE WEATHER IS FINE.
IT IS COOL.
Output:
KV KU ENQWFA.
RAIN MAY IT.
VJG YGCVJGT KU HKPG.
COOL IS IT.
Input: n=13
Output: INVALID ENTRY

SOLUTION:

import java.io.*;
public class Sentence
{
//Declare Instance variables
    String str[]; //to store original strings
    String encryp[];//to store encrypted strings
    int n;//to store number of strings
    int count;//to be used in the methods encrypt and reverse
    //Method to input data
    void takeInput() throws IOException
    {
        BufferedReader inp=new BufferedReader(new InputStreamReader(System.in));
        String s;
        count=0;
        System.out.print(“n =\t”);
        n=Integer.parseInt(inp.readLine());
        if(n< 1 || n >9)
            System.out.println(“\nINVALID ENTRY:”);
        else
        {
            str=new String[n];
            encryp=new String[n];
            System.out.println(“\nEnter sentences terminated with full stop”);
            for(int x=0;x< n;x++)
            {            s=inp.readLine().trim();
                if(s.charAt(s.length()-1)!=’.’)
                {
                    System.out.println(“\nSentence must terminate with a Full stop. Enter again.”);
                    x–;
                    continue;
                }
                else
                    str[x]=s;
            }//EndFor
            callEncryption();
        }//EndElse
    }//End Method
    //Method to extract strings and encrypt
    void callEncryption()
    {
        for(int x=0;x< n;x++)
        {
            if(x%2==0)
                encrypt(str[x]);
            else
                reverse(str[x]);
        }//EndFor
    }//EndMethod
    //Method to encrypt string
    void encrypt(String s)
    {
        char ch;
        String temp=””;
        int len=s.length();
        for(int x=0;x< len;x++)
        {
            ch=s.charAt(x);
            if((ch>=65 && ch<=90)||(ch>=97 && ch<=122))
            {
                ch=(char)(ch+2);
                if(ch>90 && ch<97)
                {
                    ch=(char)((64+ch-90));
                }
                else if(ch>122)
                {
                    ch=(char)((96+ch-122));
                }
            }//Endif
            temp=temp+ch;
        }//EndFor
        encryp[count]=temp;
        count++;
    }//EndMethod
    //Method to Reverse String
    void reverse(String s)
    {
        int x;
        String s1, word=””;
        s=s.substring(0,s.length()-1);
        while(true)
        {
            x=s.lastIndexOf(” “);
            if(x<0)
                break;
            s1=s.substring(x).trim();
            word+=s1+”  “;
            s=s.substring(0,x).trim();
        }//EndWhile
        word+=s;
        encryp[count]=word;
        count++;
    }//EndMethod
//Method to print encrypted strings
void showOutput()
    {
System.out.println(“\nOutput:”);
        for(int x=0;x<count;x++)
            System.out.println(encryp[x]);
    }//EndMethod
    //Main method to call other methods
    public static void main(String args[]) throws IOException
    {
        Sentence obj=new Sentence();
        obj.takeInput();
        obj.showOutput();
    }//EndMain
}//EndClass
------------------end---------------

Question 3.

Design a program which accepts your date of birth in dd mm yyyy format. Check whether the date entered is valid or not. If it is valid, display “VALID DATE”, also compute and display the day number of the year for the date of birth. If it is invalid, display “INVALID DATE” and then terminate the program.
Test your program  for the given sample data and some random data.
Input:
Enter your date of birth in dd mm yyyy format
05
01
2010
Output:
VALID DATE
5
Input:
Enter your date of birth in dd mm yyyy format
03
04
2010
Output:
VALID DATE
93
Input:
Enter your date of birth in dd mm yyyy format
34
06
2010
Output:
INVALID DATE

SOLUTION:

import java.io.*;
public class ISC
{
//Declare Instance variable
int d,m,y;
    //Method to input date
    void takeInput() throws IOException
    {
        BufferedReader inp=new BufferedReader(new InputStreamReader(System.in));
        System.out.println(“Enter your date of birth in dd mm yyyy format:”);
        d=Integer.parseInt(inp.readLine());
        m=Integer.parseInt(inp.readLine());
        y=Integer.parseInt(inp.readLine());
    }//EndMethod
//Method to check validity of date
    void checkValidity()
    {
        int days[]={31,28,31,30,31,30,31,31,30,31,30,31};
        int dateToDays=0;
        //Check year is leap or not
        int l=checkLeap(y);
        days[1]+=l;//to add 1 to feb if year is leap
        if(m<=0 || m>12  || d<=0 || d>days[m-1] || y<=0 )
            System.out.println(“INVALID DATE”);
        else
        {
            for(int x=0;x< m-1;x++)
            {
                dateToDays+=days[x];
            }//EndFor
           dateToDays+=d;//to add days of the current month
            System.out.println(“\nVALID DATE\n”+ dateToDays);
        }//ENDELSE
    }//ENDMETHOD
    //Method to find and return year is leap or not
    int checkLeap(int year)
    {
        if (year% 4 == 0)
        {
            if (year % 100 != 0)
                return 1;
            else if (year % 400 == 0)
                return 1;
            else
                return 0;
        }
        else
            return 0;
    }//EndMethod
    //Main method to call other methods
    public static void main(String args[]) throws IOException
    {
        ISC obj=new ISC
        obj.takeInput();
        obj.checkValidity();
    }//EndMain
}//EndMethod

------------------end-------------------

Friday, 12 April 2019

ISC Practical Paper – 2012 (Solved)

ISC Practical Paper – 2012 (Solved)

Question 1.

A prime palindrome integer is a positive integer (without leading zeros) which is prime as well as a palindrome. Given two positive integers m and n, where m<= n, write a program to determine how many prime-palindrome integers are there in the range between m and n (both inclusive) and output them.

The input contains two positive integers m and n where m>=100 and n<= 3000. Display number of prime palindrome integers in the specified range along with their values in the format specified below:

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

Example 1:

INPUT:

M=100

N=1000

OUTPUT: The prime palindrome integers are:

101,131,151,181,191,313,351,373,383,727,757,787,797,919,929

Frequency of prime palindrome integers: 15

Example 2:

INPUT:

M=100

N=5000

OUTPUT: Out of Range

Solution:

import java.io.*;

class PrimeP
{
    public void showPrimePal() throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int m,n, c=0;
        System.out.println(“Enter the Lower Limit:”);
        m=Integer.parseInt(br.readLine());
        System.out.println(“Enter the Upper Limit:”);
        n=Integer.parseInt(br.readLine());
        if(m>n || n>3000)
            System.out.println(“Out of Range.”);
        else
        {
            System.out.println(“The Prime Palindrome integers are:”);
            while(m<=n)
            {
                if(checkPrimePal(m))
                {
                    if(c==0)
                        System.out.print(m);
                    else
                        System.out.print(“, “+m);
                    c++;
                }
                m++;
            }
            System.out.println(“\nFrequency of Prime Palindrome integers: “+c);
        }
    }
    boolean checkPrimePal(int x)
    {
        boolean flag=false;
        int c=0, temp=x;
        int rev=0,rem=0;
        for(int i=1;i<=x;i++)
        {
            if(x%i==0)
                c++;
        }
        if(c<=2)
        {
            while(x!=0)
            {
                rem=x%10;
                rev=rev*10+rem;
                x/=10;
            }
            if(rev==temp)
                flag=true;
        }
        return flag;
    }
    public static void main(String args[]) throws IOException
    {
        PrimeP ob=new PrimeP ();
        ob.showPrimePal();
    }
}
------------------end--------------------------

Question 2.

 Write a program to accept a sentence as input. The words in the string are to be separated by a blank. Each word must be in upper case. The sentence is terminated by either “.”,”!” or “?”. Perform the following tasks:

(i)  Obtain the length of the sentence. (measured in words)

(ii) Arrange the sentence in alphabetical order of the words.

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

Example 1:

INPUT: NECESSITY IS THE MOTHER OF INVENTION.

OUTPUT:

Length: 6

Rearranged Sentence:

INVENTION IS MOTHER NECESSITY OF THE

Example 2:

INPUT: BE GOOD TO OTHERS.

OUTPUT:

Length: 4

Rearranged Sentence: BE GOOD OTHERS TO

Solution:

import java.io.*;
class WordsInSentence
{
    public void take() throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String str, words[], stk=””;
        int i,j,c=0,flag, len;
        char ch;
        while(true)
        {
            flag=0;
            System.out.println(“Enter the sentence:”);
            str=br.readLine();
            len= str.length();
            words=new String[len];
            for(i=0;i
            {
                if(Character.isLowerCase(str.charAt(i)))
                {
                    flag=1;
                    break;
                }
            }
            if (flag==0)
                break;
            else
                System.out.println(“Enter the sentence again with all uppercase letters”);
        }
        i=0;
        while(i<len)
        {
            ch=str.charAt(i);
            if(ch==’ ‘|| ch==’.’ || ch==’?’ || ch==’!’)
            {
                words[c]=stk;
                c++;
                i++;
                stk=””;
            }
            else
            {
                stk+=ch;
                i++;
            }
        }
        for(i=0;i<c;i++)
        {
            for(j=0;j<c-1;j++)
            {
                if((words[j].compareTo(words[j+1]))>0)
                {
                    stk=words[j];
                    words[j]=words[j+1];
                    words[j+1]=stk;
                }
            }
        }
        System.out.println(“Length= “+c);
        System.out.println(“\nRearranged Sentence:\n”);
        for(i=0;i<c;i++)
            System.out.print(words[i]+” “);
    }
    public static void main(String args[]) throws IOException
    {
        WordsInSentence ob=new WordsInSentence();
        ob.take();
    }
}
------------------end------------------------

Question 3.

Write a program to declare a matrix A [][] of order (MXN) where ‘M’ is the number of rows and ‘N’ is the number of columns such that both M and N must be greater than 2 and less than 20. Allow the user to input integers into this matrix. Perform the following tasks on the matrix:

Display the input matrix
Find the maximum and minimum value in the matrix and display them along with their position.
Sort the elements of the matrix in ascending order using any standard sorting technique and rearrange them in the matrix.
Output the rearranged matrix.
Test your program with the sample data and some random data:

Example 1.

INPUT:

M=3

N=4

Entered values: 8,7,9,3,-2,0,4,5,1,3,6,-4

 OUTPUT:

Original matrix:

8  7  9  3

-2  0  4  5

1  3  6  -4

Largest Number: 9

Row: 0

Column: 2

Smallest Number: -4

Row=2

Column=3

Rearranged matrix:

-4  -2  0  1

3  3  4  5

6  7  8  9

Solution: 

import java.util.*;
class Matrix
{
public static void main(String args[])
{  
int p=0,smallest=4999,larger=0,maxr=0,maxc=0,minr=0,minc=0;
Scanner sc=new Scanner(System.in);
System.out.println("enter m*n");
int m=sc.nextInt();
int n=sc.nextInt();
int a[][]=new int[m][n];
int b[]=new int[1000];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
a[i][j]=sc.nextInt();
}
}

for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]<smallest)
{
smallest=a[i][j];
maxr=i;
maxc=j;
}
if(a[i][j]>larger)
{
larger=a[i][j];
minr=i;
minc=j;
}
}
}
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
b[p]=a[i][j];
p++;
}
}

for(int i=0;i<p;i++)
{
for(int j=0;j<p-i-1;j++)
{
if(b[j]>b[j+1])
{
int temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
p=0;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
System.out.print(b[p]+"\t");
p++;
}
System.out.println();
}
System.out.println("largest"+"="+larger);
System.out.println("Row : "+minr);
System.out.println("Column : "+minc);
System.out.println("smallest"+"="+smallest);
System.out.println("Row : "+maxr);
System.out.println("Column : "+maxc);
}
}

-------------------end----------------------------

Thursday, 11 April 2019

ISC COMPUTER SCIENCE PRACTICAL 2019 SOLVED

ISC COMPUTER SCIENCE PRACTICAL 2019

QUESTION 1:

Design a program to accept a day number (between 1 and 366), year(in 4 digits) from the user to generate and display the corresponding date. Also, accept ‘N’ ( 1<= N <= 100) from the user to compute and display  the future date corresponding to ‘N’ days after the generated date. Display an error message if the value of the day number, year and N are not within the limit or not according to the condition specified.
Test your program with the following data and some random data:
INPUT:

EXAMPLE 1: DAY NUMBER:                  255
                        YEAR:                                  2018
                        DATE AFTER (N DAYS):    22
OUTPUT:       DATE:                                   12 TH SEPTEMBER, 2018
                        DATE AFTER 22 DAYS      4 TH OCTOBER, 2018

Solution:

import java.util.*;
public class Date 
{
    public static void main(String[] args) 
{
       int day_num;
             int yr;
             int N;
        Scanner in = new Scanner(System.in);
        DaysCalculation date = new DaysCalculation();
        do 
      {
                    System.out.println("Enter a day number (between 1 and 366)");
                    day_num = in.nextInt();
                    if(day_num < 1 || day_num > 366)
                                 System.out.println("INVALID DAY NUMBER:");
                    }
      while(day_num < 1 || day_num > 366);
            
             do 
         {
                    System.out.println("Enter the year");
                    yr = in.nextInt();
                    if(Integer.toString(yr).length()!=4)
                                 System.out.println("INVALID YEAR:");
                    }
                       while(Integer.toString(yr).length()!=4);
             do  
                     {
                    System.out.println("Enter the value of N:");
                    N = in.nextInt();
                    if(N < 1 || N > 100)
                                 System.out.println("INVALID DAY NUMBER (between 1 and 100):");
                    }
                    while(N < 1 || N > 100);
           date.setDate(day_num,yr,N);  
           System.out.println("OUTPUT:");
           date.dateSpecifier(); 
          in.close();
        }   
    }
      class DaysCalculation  
       {
    public void setDate(int dayNumber, int year, int dayAfter) 
      {
        this.dayNumber = dayNumber;
        this.year = year;
        this.dayAfter = dayAfter;
        }
    public void dateSpecifier() 
       {
        int m = 0,k=1;
        for(int i = 1; i <= dayNumber; i++) 
             {
            if( checkLeap(year) == true ? k > ldays[m] : k > mdays[m] ) 
              {
                k = 1;
                m++;
                }
            k++;   
            }
        String prefix;   
        prefix = (k-1)%10 == 1 ? "st" : (k-1)%10 == 2 ? "nd" : (k-1)%10 == 3 ? "rd" : "th";
        System.out.println("DATE:     "+(k-1)+prefix+" "+months[m]+" ,"+year); 
        for (int i = 1; i <= dayAfter; i++) 
            {
            if( checkLeap(year) == true ? k > ldays[m] : k > mdays[m] ) 
               {
                k = 1;
                m++;
                if(m > 11) 
                   {
                    year++;
                    m = 0;
                    }
                }
            k++;   
            }
        prefix = (k-1)%10 == 1 ? "st" : (k-1)%10 == 2 ? "nd" : (k-1)%10 == 3 ? "rd" : "th";
        System.out.println("DATE AFTER "+dayAfter+" DAYS:"+(k-1)+""+prefix+" "+months[m]+"  ,"+year);       
        }   
    private boolean checkLeap(int year)  
         {
        if(year%400==0)
           leap=true;
        else if (year%100==0)
           leap=false;
        else if (year%4==0)
           leap=true;
        else
           leap=false;
           return leap;
        }    
    private boolean flag;
    private static boolean leap;   
    private int dayNumber,year;
    private int dayAfter;
    String[] months = {"January","Feburary","March","April","May","June","July","August","Sepetember","October","November","December"};
    int[] mdays={31,28,31,30,31,30,31,31,30,31,30,31};
    int[] ldays={31,29,31,30,31,30,31,31,30,31,30,31};   
    }

NOTE: THIS PROBLEM ALREADY CAME IN ISC 2009 COMPUTER SCIENCE PRACTICAL
-------------------end---------------------------

QUESTION 2:

Write a program to declare a single dimensional array a[] and a square matrix b[][]
of size N, where N > 2 and N < 10. Allow the user to input positive integers into
the single dimensional array.
Perform the following task on the matrix:

(a) Sort the elements of the single dimensional array in ascending order using any sorting technique
      and display the sorted elements.

(b)  Fill the matrix b[][] in the following format.
       If the array a[] ={5,2,8,1} then after sorting, a[]={1,2,5,8}
       then the matrix b[][] would fill as below:
                1   2   5   8
                1   2   5   1
                1   2   1   2
                1   1   2   5

(c)  Display the filled matrix in the above format

Test your program for some random data.
 Example 1:
INPUT N=3
            ENTER ELEMENTS OF SINGLE DIMENSIONAL ARRAY: 3 1 7

OUTPUT:  SORTED ARRAY :1 3 7
FILLED MATRIX
1 3 7
1 3 1
1 1 3

Solution:

import java.util.*;
class Matrix2019
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter");
int N=sc.nextInt();
if(N<2||N>10)
{
System.out.println("MATRIX SIZE OUT OF RANGE");
}
else
{
int a[]=new int[1000];
int b[][]=new int[100][100];
System.out.println("ENTER ELEMENT OF SINGLE DIMENSIONAL ARRAY:");
for(int i=0;i<N;i++)
{
a[i]=sc.nextInt();
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N-i-1;j++)
{
if(a[j]>a[j+1])
{
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
///for printing sorted array....
System.out.print("SORTED ARRAY :");
for(int i=0;i<N;i++)
{
System.out.print(a[i]);
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
if(j<N-i)
b[i][j]=a[j];
else
b[i][j]=a[j-(N-i)];
}
}
System.out.println("FILLED MATRIX");
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
System.out.print(b[i][j]);
}
System.out.println();
}
}
}
}
--------------end-----------------


Question 3

Write a program to accept a sentence which may be terminated by either '.', '?' or '!'
only. The words are to be entered by  a single blank space and re in UPPER CASE.

Perform the following tasks:
(a) Check for validity for the entered sentence.
(b) Convert the non-palindrome words of the sentence into palnidrome words by

      concatenating the word by its revers (excluding the last character).
      Example: The reverse of the word HELP would be LEH (omitting the
      last alphabet) and by concatenating both, the new palindrome word is HELPLEH.
      Thus the word HELP become HELPLEH

  Note: The words which end with repeated alphabets, for example ABB would
             become ABBA and not ABBBA and XAZZZ becomes XAZZZAX.

(c) Display the original sentence along with converted sentence.
   
Test your program for the following data and some random data:
Example 1:
INPUT: THE BIRD IS FLYING.
OUTPUT: THE BIRD IS FLYING.
                 THEHT BIRDRID ISI FLYINGNIYLF
Example 2:
INPUT: YOU MUST BE CRAZY#
OUTPUT: INVALID INPUT

Solution:

import java.util.*;
class MakePalindrome
{
   private String s,rs;
   public MakePalindrome()
   {
       s="";
       rs="";
    }
    public Boolean input()
    {
        int l;
        char ch;
        Scanner sc=new Scanner(System.in);
        System.out.println("enter the Sentence");
        s=sc.nextLine();
        l=s.length();
        ch=s.charAt(l-1);
        if(!(ch=='.'||ch=='?'||ch=='!'))
        {
            System.out.println("INVALID INPUT");
            return false;
        }
        else
        {
            return true;
        }
    }
    public void process()
    {
        String w,suffix;
        int l,wl,i;
        char ch;
        l=s.length();
        ch=s.charAt(l-1);
        String ns=s.substring(0,l-1);
        StringTokenizer st = new StringTokenizer(ns);
        while(st.hasMoreTokens())
        {
            w=st.nextToken();
            wl=w.length();
            i=0;
            suffix="";
            while(!isPalindrome(w+suffix))
            {
                suffix = w.charAt(i) + suffix;
                i++;
            }
            rs=rs + " " + w+suffix;
        }
        rs =rs.substring(l);
    }
    public void display()
    {
        System.out.println("Result is:");
        System.out.println(rs);
    }
    public boolean isPalindrome(String s)
    {
        String r="";
        int l,i;
        l=s.length();
        for(i=0;i<l;i++)
        {
            r=s.charAt(i) +r;
        }
        return s.equals(r);
    }
    public static void main(String args[])
    {
        MakePalindrome ob = new MakePalindrome();
        if(ob.input())
        {
            ob.process();
            ob.display();
        }
    }
}
------------------end-----------------------