Friday , 20 January 2017
Home » Class 12 » [Question 3] ISC 2015 Computer Practical Paper Solved

[Question 3] ISC 2015 Computer Practical Paper Solved

Click here to download the complete ISC 2015 Computer Science Paper 2 (Practical).


Write a program to accept a sentence which may be terminated by either ‘.’ or ‘?’ only. The words are to be separated by a single blank space. Print an error message if the input does not terminate with ‘.’ or ‘?’. You can assume that no word in the sentence exceeds 15 characters, so that you get a proper formatted output.

Perform the following tasks:
(i) Convert the first letter of each word to uppercase.
(ii) Find the number of vowels and consonants in each word and display them with proper headings along with the words.

Test your program with the following inputs.

Example 1

INPUT: Intelligence plus character is education.

Intelligence Plus Character Is Education

Word Vowels Consonants
Intelligence 5 7
Plus 1 3
Character 3 6
Is 1 1
Education 5 4

Example 2

INPUT: God is great.

God is Great

Word Vowels Consonants
God 1 2
Is 1 1
Great 2 3

Example 3

INPUT: All the best!

Invalid Input.

Programming Code:

* The class Q3_ISC2015 inputs a sentence, converts the first letter of each word to
* uppercase and find the number of vowels and consonants
* @author :
* @Program Type : BlueJ Program - Java
* @Question Year : ISC Practical 2015 Question 3
import java.util.*;
class Q3_ISC2015
    int countVowel(String s) // Function to count no. of vowels in a word
        s = s.toUpperCase();
        int count = 0;
        char ch;
        for(int i=0; i<s.length(); i++)
            ch = s.charAt(i);
            if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
        return count;
    String convert(String s) // Function to convert 1st character to UpperCase
        char ch = s.charAt(0); // Extracting the first character
        ch = Character.toUpperCase(ch); // Converting that character to UpperCase
        String f = ch + s.substring(1); // Adding it with the rest of the string
        return f;
    String addSpace(String s, int max) // Function for addng extra space to make every word equal in length
        int x = max-s.length();
        for(int i=1; i<=x; i++)
            s = s+" ";
        return s;
    public static void main(String args[])
        Q3_ISC2015 ob = new Q3_ISC2015();
        Scanner sc=new Scanner(;
        System.out.print("Enter a sentence : ");
        String s=sc.nextLine();
        int l = s.length();
        char last = s.charAt(l-1); // Extracting the last character
        /* Checking whether the sentence ends with '.' or '?' or not */
        if(last != '.' && last != '?')
            System.out.println("Invalid Input. End a sentence with either '.' or '?'");
            StringTokenizer str = new StringTokenizer(s," .?");
            int x = str.countTokens();
            String ans="";
            String word[]=new String[x];
            int vow, con, max=0;
            for(int i=0; i<x; i++)
                word[i] = str.nextToken(); // Extracting words and saving them in an array
                ans = ans + " " + ob.convert(word[i]);
                    max = word[i].length();
            System.out.println("Sentence = "+ans.trim());
            String y=ob.addSpace("Word",max);
            for(int i=0; i<x; i++)
                vow = ob.countVowel(word[i]);
                con = word[i].length()-vow; // Consonant = Length - Vowel
                y = ob.addSpace(word[i],max);


Enter a sentence : God is great.
Sentence = God Is Great

Word Vowels Consonants
God 1 2
Is 1 1
Great 2 3

Enter a sentence : All the best!
Invalid Input. End a sentence with either ‘.’ or ‘?’

Check Also

ISC 2016 Computer Science Solution + Examiner’s Comments – From the Council

Solution of ISC 2016 Computer science Paper as provided by the Council for the Indian School Certificate Examinations.


  1. Hello Sir!
    In my written paper, there were a few mistakes, such as printing the output in the wrong order, i.e. the sentence after the vowel count and forgetting the throws statement. I made these changes in the practical, do you think marks would be deducted for this? And thank you for doing this, it’s really helpful!

  2. Why is “t” printed in “tVowelstConsonants” and in (y+”t”+vow+”t”+con) ??

    I wanted to thank you for the wonderful effort you’re taking. 🙂

  3. I did everything correct and the program worked fine …. but I got incorrect output for just the first input eg. ,, others worked flawless ,,, how much marks will be deducted ?

  4. Sir, instead of checking the last character as ‘.’ or ‘?’ by putting the condition if(last != ‘.’ && last !=’?’);
    I have written the code as if(last != ‘.’ || last != ‘?’);.Code for Rest of the program is all same. how much marks will I lose for using the wrong symbol in the if condition??

    • Your written condition will make even a sentence with valid ending (like having ‘.’ or ‘?’) as invalid. But in the end, it all depends on the visiting examiner. He/she may overlook these mistakes.

  5. Sir,
    Ive attempted the first question. Ive successfuly run the exact program that i’ve written and have got the perfect output. Will i get full marks?


    Sir I did not number question 3 .How many marks will be deducted?

  7. Sir my program written on paper was not working so I wrote improved program on practical. Will I loose all my marks? Hoping for a reply. Thanks.

  8. Sir I’ve attempted question 3 …but slightly changed the code while doing it on the machine….will it create a problem?????……but my output was correct and in the given format…

  9. sir the output is not in the format for sentence having more than 10 characters…

  10. –OUTPUT—–
    Enter a sentence : intelligence plus character is education.
    Sentence = Intelligence Plus Character Is Education
    Word Vowels Consonant
    intelligence 5 7
    plus 1 3
    character 3 6
    is 1 1
    education 5 4
    (Even this program doesn’t give in proper format for big sentence…the question specifically mentioned output shud be in proper to achieve so?)

  11. Did the same !
    However didn’t get proper alignment and formatted output for example 1
    Will there be any deductions?
    * A 1000 eulogies in your name for helping us out *

Leave a Reply to Aishwarya Cancel reply

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