×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
JAVA Practical Question ISC 2016 Solve - Circular Prime Java Inheritance Examples
JAVA Practical ISC 2016 Solve - Start and End Vowel - Java
5427    Arnab De    10/08/2019

This program is selected from ISC 2016 Computer Science or Class 12 practical paper.

Write a program to accept a sentence which may be terminated by either ‘.’, ‘?’ or ‘!’ only. The words may be separated by more than one blank space and are I UPPER CASE.

Perform the following tasks:

  1. Find the numbers of words beginning and ending with a vowel.
  2. Place the words which begin and end with a vowel at the beginning, followed by the remaining words as they occur in the sentence.
softetechnologies

Example 1:

INPUT:ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE.

OUTPUT:NUMBER OF WORDS BEGINNING AND ENDING WITH VOWEL = 3

ANAMIKA ARE ANYMORE AND SUSAN NEVER GOING TO QUARREL.

import java.util.*;
public class BegEndVowel
{
    public static void main(String []args)
    {
        Scanner sc=new Scanner(System.in);
        BegEndVowel bev=new BegEndVowel();
        System.out.print("Enter Your String : ");
        String str=sc.nextLine();
        int len=str.length();
        char ch=str.charAt(len-1);
        String res="";
        String temp="";
        if(ch=='.' || ch=='?' || ch=='!')
        {
            String []words=str.substring(0,len-1).split(" ");
            int c=0;
            for(int i=0;i<words.length;i++)
            {
                if(words[i].length()>0)
                {
                    if(bev.checkword(words[i]))
                    {
                        c++;
                        res += words[i] + " ";
                    }
                    else
                    {
                        temp += words[i] + " ";
                    }
                }   
             }
             System.out.println("NUMBER OF WORDS BEGINNING AND ENDING WITH VOWEL = " + c);
             res = (res + temp).trim();
             System.out.println(res);
        }
        else
        {
           System.out.println("INVALID INPUT");
        }
    }
    boolean checkword(String s)
    {
        int len=s.length();
        char ch1=s.charAt(0);
        char ch2=s.charAt(len-1);
        if((ch1=='A' || ch1=='E' || ch1=='I' || ch1=='O' || ch1=='U') && (ch2=='A' || ch2=='E' || ch2=='I' || ch2=='O' || ch2=='U'))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}
softetechnologies

Example 1

Enter Your String : ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE.
NUMBER OF WORDS BEGINNING AND ENDING WITH VOWEL = 3
ANAMIKA ARE ANYMORE AND SUSAN NEVER GOING TO QUARREL

Example 2

Enter Your String : YOU MUST AIM TO BE A BETTER PERSON TOMORROW THAN YOU ARE TODAY.
NUMBER OF WORDS BEGINNING AND ENDING WITH VOWEL = 2
A ARE YOU MUST AIM TO BE BETTER PERSON TOMORROW THAN YOU TODAY

Example 3

Enter Your String : LOOK BEFORE YOU LEAP.
NUMBER OF WORDS BEGINNING AND ENDING WITH VOWEL = 0
LOOK BEFORE YOU LEAP

Example 4

Enter Your String : HOW ARE YOU@
INVALID INPUT

JAVA Practical Question ISC 2016 Solve - Circular Prime Java Inheritance Examples
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Aristotle
Educating the mind without educating the heart is no education at all.
Aristotle
4353
40.91
Today So Far
Total View (Lakh)
softetechnologies
01/01/2018     34530
26/05/2018     32724
28/06/2017     31338
02/08/2017     29642
25/06/2018     27478
15/05/2017     24907
01/08/2017     24107
06/07/2017     23632
21/04/2018     19454
14/07/2017     19143
softetechnologies