Words that start and end with a vowel program: ISC 2016 program
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 in UPPER CASE.
Watch java videos
words that start and end with a vowel program.
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 in UPPER CASE.
Perform the following tasks:
(a) Find the number of words beginning and ending with a vowel.
(b) Place the words which begin and end with a vowel at the beginning, followed by the remaining words as they occur in the sentence.
Test your program for words that start and end with a vowel with the sample data and some random data:
words that start and end with a vowel
Example 1
INPUT: ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE.
OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 3
ANAMIKA ARE ANYMORE AND SUSAN NEVER GOING TO QUARREL
Example 2
INPUT: YOU MUST AIM TO BE A BETTER PERSON TOMORROW THAN YOU ARE TODAY.
OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 2
A ARE YOU MUST AIM TO BE BETTER PERSON TOMORROW THAN YOU TODAY
Example 3
INPUT: LOOK BEFORE YOU LEAP.
OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A OWEL= 0
LOOK BEFORE YOU LEAP
Example 4
INPUT: HOW ARE YOU@
OUTPUT: INVALID INPUT
import java.util.*;
public class StartEndVowel
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the String");
String str=sc.nextLine().toUpperCase();//taking input and converting to Uppercase
int len=str.length();
char ch=str.charAt(len-1);//last character in the string
if(ch=='.'||ch=='!'||ch=='?')//checking if the string ends with valid symbols
{
str=str.substring(0,len-1);//removing the full stop or exclamation mark
String arr[]=str.split(" ");
String vowel="";//for the words that start and end with vowels
String notvowel="";//for other words
int count=0;//to count the number of words that start and end with vowels
for(int i=0;i<arr.length;i++)
{
String temp=arr[i];
int l=temp.length();
char start=temp.charAt(0);
char end=temp.charAt(l-1);
if(start=='A'||start=='E'||start=='I'||start=='O'||start=='U')//checking
{
if(end=='A'||end=='E'||end=='I'||end=='O'||end=='U')
{
vowel+=temp+" ";
count++;
}
else
notvowel+=temp+" ";//here the word does not end with vowel
}
else
notvowel+=temp+" ";//neither starts nor ends with vowels
}
String result=vowel+notvowel;//just concatenating both strings
System.out.println("Words starting and ending with vowels are "+count);
System.out.println(result);
}
else
System.out.println("INVALID INPUT");
}
}
Download free Sample papers
Related Posts
Continue learning with these related articles

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.

Boolean Algebra for ISC Class 12: Laws, Canonical SOP and POS, and Simplification
ISC Class 12 Computer Science notes on Boolean algebra: all the laws and theorems, duality, De Morgan's laws, minterms and maxterms, converting to canonical SOP and POS, and step-by-step algebraic simplification with solved examples.