Project File Questions
Project File Questions
Question 1
A Prime-Adam integer is a positive integer (without leading zeros) which is a prime as well as an
Adam number.
Prime number: A number which has only two factors, i.e. 1 and the number itself.
Adam number: The square of a number and the square of its reverse are reverse to each other.
(13)2 = 169
Accept two positive integers m and n, where m is less than n as user input. Display all Prime-Adam
integers that are in the range between m and n (both inclusive) and output them along with the
frequency, in the format given below:
Test your program with the following data and some random data:
Example 1
INPUT:
m=5
n = 100
OUTPUT:
THE PRIME-ADAM INTEGERS ARE:
11 13 31
FREQUENCY OF PRIME-ADAM INTEGERS IS: 3
Example 2
INPUT:
m = 100
n = 200
OUTPUT:
THE PRIME-ADAM INTEGERS ARE:
101 103 113
FREQUENCY OF PRIME-ADAM INTEGERS IS: 3
Example 3
INPUT:
m = 50
n = 70
OUTPUT:
THE PRIME-ADAM INTEGERS ARE:
NIL
FREQUENCY OF PRIME-ADAM INTEGERS IS: 0
Example 4
INPUT:
m = 700
n = 450
OUTPUT:
INVALID INPUT
Solution
import java.util.Scanner;
int rev = 0;
while (num != 0) {
rev = rev * 10 + d;
num /= 10;
return rev;
int c = 0;
if (num % i == 0) {
c++;
return c == 2;
int m = in.nextInt();
int n = in.nextInt();
int count = 0;
if (m >= n) {
System.out.println("INVALID INPUT");
return;
if (prime) {
count++;
if (count == 0) {
System.out.print("NIL");
System.out.println();
Output
Q. 2
A company manufactures packing cartons in four sizes, i.e. cartons to accommodate 6 boxes, 12
boxes, 24 boxes and 48 boxes. Design a program to accept the number of boxes to be packed (N) by
the user (maximum up to 1000 boxes) and display the break-up of the cartons used in descending
order of capacity (i.e. preference should be given to the highest capacity available, and if boxes left
are less than 6, an extra carton of capacity 6 should be used.)
Test your program with the following data and some random data:
Example 1
INPUT:
N = 726
OUTPUT:
48 * 15 = 720
6*1=6
Remaining boxes = 0
Total number of boxes = 726
Total number of cartons = 16
Example 2
INPUT:
N = 140
OUTPUT:
48 * 2 = 96
24 * 1 = 24
12 * 1 = 12
6*1=6
Remaining boxes = 2 * 1 = 2
Total number of boxes = 140
Total number of cartons = 6
Example 3
INPUT:
N = 4296
OUTPUT:
INVALID INPUT
Solution
import java.util.Scanner;
System.out.println("INVALID INPUT");
return;
int total = 0;
int t = n;
t = t % cartonSizes[i];
total += cartonCount;
if (cartonCount != 0) {
/*
*/
if (t != 0) {
total++;
}
else {
Output
Question 3
A Circular Prime is a prime number that remains prime under cyclic shifts of its digits. When the
leftmost digit is removed and replaced at the end of the remaining string of digits, the generated
number is still prime. The process is repeated until the original number is reached again.
A number is said to be prime if it has only two factors 1 and itself.
Example:
131
311
113
Hence, 131 is a circular prime.
Accept a positive number N and check whether it is a circular prime or not. The new numbers
formed after the shifting of the digits should also be displayed.
Test your program with the following data and some random data:
Example 1
INPUT:
N = 197
OUTPUT:
197
971
719
197 IS A CIRCULAR PRIME.
Example 2
INPUT:
N = 1193
OUTPUT:
1193
1931
9311
3119
1193 IS A CIRCULAR PRIME.
Example 3
INPUT:
N = 29
OUTPUT:
29
92
29 IS NOT A CIRCULAR PRIME.
Solution
import java.util.Scanner;
{
public static boolean isPrime(int num) {
int c = 0;
if (num % i == 0) {
c++;
return c == 2;
int c = 0;
while (num != 0) {
c++;
num /= 10;
return c;
int n = in.nextInt();
if (n <= 0) {
System.out.println("INVALID INPUT");
return;
}
if (isPrime(n)) {
System.out.println(n);
int n2 = n;
int t1 = n2 / divisor;
int t2 = n2 % divisor;
n2 = t2 * 10 + t1;
System.out.println(n2);
if (!isPrime(n2)) {
isCircularPrime = false;
break;
else {
isCircularPrime = false;
if (isCircularPrime) {
else {
}
}
Output
Question 4
A Goldbach number is a positive even integer that can be expressed as the sum of two odd primes.
Note: All even integer numbers greater than 4 are Goldbach numbers.
Example:
6=3+3
10 = 3 + 7
10 = 5 + 5
Hence, 6 has one odd prime pair 3 and 3. Similarly, 10 has two odd prime pairs, i.e. 3 and 7, 5 and 5.
Write a program to accept an even integer 'N' where N > 9 and N < 50. Find all the odd prime pairs
whose sum is equal to the number 'N'.
Test your program with the following data and some random data:
Example 1
INPUT:
N = 14
OUTPUT:
PRIME PAIRS ARE:
3, 11
7, 7
Example 2
INPUT:
N = 30
OUTPUT:
PRIME PAIRS ARE:
7, 23
11, 19
13, 17
Example 3
INPUT:
N = 17
OUTPUT:
INVALID INPUT. NUMBER IS ODD.
Example 4
INPUT:
N = 126
OUTPUT:
INVALID INPUT. NUMBER OUT OF RANGE.
Solution
import java.util.Scanner;
int c = 0;
if (num % i == 0) {
c++;
return c == 2;
int n = in.nextInt();
return;
if (n % 2 != 0) {
return;
int a = 3;
int b = 0;
while (a <= n / 2) {
b = n - a;
a += 2;
Output
Question 5
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:
Example 1
INPUT:
DAY NUMBER: 255
YEAR: 2018
DATE AFTER (N DAYS): 22
OUTPUT:
DATE: 12TH SEPTEMBER, 2018
DATE AFTER 22 DAYS: 4TH OCTOBER, 2018
Example 2
INPUT:
DAY NUMBER: 360
YEAR: 2018
DATE AFTER (N DAYS): 45
OUTPUT:
DATE: 26TH DECEMBER, 2018
DATE AFTER 45 DAYS: 9TH FEBRUARY, 2019
Example 3
INPUT:
DAY NUMBER: 500
YEAR: 2018
DATE AFTER (N DAYS): 33
OUTPUT:
DAY NUMBER OUT OF RANGE
Example 4
INPUT:
DAY NUMBER: 150
YEAR: 2018
DATE AFTER (N DAYS): 330
OUTPUT:
DATE AFTER (N DAYS) OUT OF RANGE
Solution
import java.util.Scanner;
ret = true;
else if (y % 100 == 0) {
ret = false;
else if (y % 4 == 0) {
ret = true;
else {
ret = false;
return ret;
int monthDays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if (leap) {
monthDays[1] = 29;
int i = 0;
int daySum = 0;
for (i = 0; i < monthDays.length; i++) {
daySum += monthDays[i];
break;
sb.append(date);
sb.append("TH ");
sb.append(monthNames[i]);
sb.append(", ");
sb.append(year);
return sb.toString();
System.out.print("YEAR: ");
int n = in.nextInt();
return;
}
return;
nYear = nYear + 1;
nYear = nYear + 1;
System.out.println();
Output
Array Programs:
Questions:
Question 1.
A class Mixarray contains an array of integer elements along with its capacity
(More than or equal to 3). Using the following description, form a new array of
integers which will contain only the first 3 elements of the two different arrays
one after another.
Example: Array1: { 78, 90, 100, 45, 67 }
Array2: {10, 67, 200, 90 }
Resultant Array: { 78, 90, 100, 10, 67, 200}
The details of the members of the class are given below:
Class name : Mixarray
Member functions/methods:
Mixarray (int mm ) : to initialize the capacity of the array cap=mm
void input( ) : to accept the elements of the array
Mixarray mix(Mixarray P, Mixarray Q) : returns the resultant array having the
first 3
elements of the array of objects P and Q
void display( ) : to display the array with an appropriate message.
Write a program to declare a matrix A[][] of order (M x N) where 'M' is the number of rows and 'N' is
the number of columns such that the value of 'M' must be greater than 0 and less than 10 and the
value of 'N' must be greater than 2 and less than 6. Allow the user to input digits (0 - 7) only at each
location, such that each row represents an octal number.
Example:
2. Calculate the decimal equivalent for each row and display as per the format given below.
Test your program for the following data and some random data:
Example 1:
INPUT:
M=1
N=3
ENTER ELEMENTS FOR ROW 1: 1 4 4
OUTPUT:
1 4 4 100
Example 2:
INPUT:
M=3
N=4
ENTER ELEMENTS FOR ROW 1: 1 1 3 7
ENTER ELEMENTS FOR ROW 2: 2 1 0 6
ENTER ELEMENTS FOR ROW 3: 0 2 4 5
OUTPUT:
2 1 0 6 1094
0 2 4 5 165
Example 3:
INPUT:
M=3
N=3
ENTER ELEMENTS FOR ROW 1: 2 4 8
OUTPUT:
INVALID INPUT
Example 4:
INPUT:
M=4
N=6
OUTPUT:
OUT OF RANGE
Solution
import java.util.Scanner;
int m = in.nextInt();
int n = in.nextInt();
System.out.println("OUT OF RANGE");
return;
a[i][j] = in.nextInt();
System.out.println("INVALID INPUT");
return;
int decNum = 0;
System.out.print("\t\t" + decNum);
System.out.println();
Output
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.
12581251121211251111222155128125
Test your program for the following data and 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
137131113111331713
Example 2
INPUT:
N = 13
OUTPUT:
MATRIX SIZE OUT OF RANGE
Example 3
INPUT:
N=5
ENTER ELEMENTS OF SINGLE DIMENSIONAL ARRAY: 10 2 5 23 6
OUTPUT:
SORTED ARRAY: 2 5 6 10 23
FILLED MATRIX
2561023256102256252525622561022222555526662510102562325610
Solution
import java.util.Scanner;
int n = arr.length;
for (int i = 0; i < n - 1; i++) {
int t = arr[j];
arr[j] = arr[j+1];
arr[j+1] = t;
int n = in.nextInt();
return;
a[i] = in.nextInt();
sortArray(a);
System.out.println("SORTED ARRAY:");
for (int i = 0; i < n; i++) {
b[r][j] = a[j];
System.out.println();
System.out.println("FILLED MATRIX:");
System.out.println();
Output
Question 3
The quiz has five questions with four multiple choices (A, B, C, D), with each question carrying 1 mark
for the correct answer. Design a program to accept the number of participants N such that N must be
greater than 3 and less than 11. Create a double-dimensional array of size (Nx5) to store the answers
of each participant row-wise. Calculate the marks for each participant by matching the correct
answer stored in a single-dimensional array of size 5. Display the scores for each participant and also
the participant(s) having the highest score.
Participant 1 A B B C A
Participant 2 D A D C B
Participant 3 A A B A C
Participant 4 D C C A B
Note: Array entries are line fed (i.e. one entry per line)
Test your program for the following data and some random data.
Example 1
INPUT:
N=5
Participant 1 D A B C C
Participant 2 A A D C B
Participant 3 B A C D B
Participant 4 D A D C B
Participant 5 B C A D D
Key: B C D A A
OUTPUT:
Scores:
Participant 1 = 0
Participant 2 = 1
Participant 3 = 1
Participant 4 = 1
Participant 5 = 2
Highest Score:
Participant 5
Example 2
INPUT:
N=4
Participant 1 A C C B D
Participant 2 B C A A C
Participant 3 B C B A A
Participant 4 C C D D B
Key: A C D B B
OUTPUT:
Scores:
Participant 1 = 3
Participant 2 = 1
Participant 3 = 1
Participant 4 = 3
Highest Score:
Participant 1
Participant 4
Example 3
INPUT:
N = 12
OUTPUT:
INPUT SIZE OUT OF RANGE.
Solution
import java.util.Scanner;
int n = in.nextInt();
return;
key[i] = in.next().charAt(0);
int hScore = 0;
System.out.println("Scores:");
if (answers[i][j] == key[j]) {
score[i]++;
hScore = score[i];
System.out.println("Highest Score:");
if (score[i] == hScore) {
Output
Question 4
Write a program to declare a square matrix A[][] of order (M × M) where 'M' must be greater than 3
and less than 10. Allow the user to input positive integers into this matrix. Perform the following
tasks on the matrix:
1. Sort the non-boundary elements in ascending order using any standard sorting technique
and rearrange them in the matrix.
3. Display the original matrix, rearranged matrix and only the diagonal elements of the
rearranged matrix with their sum.
Test your program for the following data and some random data:
Example 1
INPUT:
M=4
9 2 1 5
8 13 8 4
15 6 3 11
7 12 23 8
OUTPUT:
ORIGINAL MATRIX
9 2 1 5
8 13 8 4
15 6 3 11
7 12 23 8
REARRANGED MATRIX
9 2 1 5
8 3 6 4
15 8 13 11
7 12 23 8
DIAGONAL ELEMENTS
9 5
3 6
8 13
7 8
SUM OF THE DIAGONAL ELEMENTS = 59
Example 2
INPUT:
M=5
7 4 1 9 5
8 2 6 10 19
13 1 3 5 1
10 0 5 12 16
1 8 17 6 8
OUTPUT:
ORIGINAL MATRIX
7 4 1 9 5
8 2 6 10 19
13 1 3 5 1
10 0 5 12 16
1 8 17 6 8
REARRANGED MATRIX
7 4 1 9 5
8 0 1 2 19
13 3 5 5 1
10 6 10 12 16
1 8 17 6 8
DIAGONAL ELEMENTS
7 5
0 2
5
6 12
1 8
SUM OF THE DIAGONAL ELEMENTS = 46
Example 3
INPUT:
M=3
OUTPUT:
THE MATRIX SIZE IS OUT OF RANGE.
Solution
import java.util.Scanner;
int m = in.nextInt();
return;
a[i][j] = in.nextInt();
/*
* should be enetered
*/
if (a[i][j] < 0) {
System.out.println("INVALID INPUT");
return;
}
}
System.out.println("ORIGINAL MATRIX");
printMatrix(a, m);
sortNonBoundaryMatrix(a, m);
System.out.println("REARRANGED MATRIX");
printMatrix(a, m);
computePrintDiagonalSum(a, m);
/*
*/
int k = 0;
b[k++] = a[i][j];
int t = b[j];
b[j] = b[j+1];
b[j+1] = t;
k = 0;
a[i][j] = b[k++];
int sum = 0;
System.out.println("DIAGONAL ELEMENTS");
if (i == j || i + j == m - 1) {
sum += a[i][j];
System.out.print(a[i][j] + "\t");
else {
System.out.print("\t");
System.out.println();
}
System.out.println("SUM OF THE DIAGONAL ELEMENTS = " + sum);
System.out.print(a[i][j] + "\t");
System.out.println();
Output
Question 5
Write a program to declare a matrix a[][] of order (m × n) where 'm' is the number of rows and 'n' is
the number of columns such that the values of both 'm' and 'n' must be greater than 2 and less than
10. Allow the user to input integers into this matrix. Perform the following tasks on the matrix:
2. Sort each row of the matrix in ascending order using any standard sorting technique.
Test your program for the following data and some random data:
Example 1
INPUT:
M=4
N=3
11−23516790431811593−216013748
OUTPUT:
ORIGINAL MATRIX
11−23516790431811593−216013748
−23115716049138−25013743111698
Example 2
INPUT:
M=3
N=3
2251973612913622795361319126
OUTPUT:
ORIGINAL MATRIX
2251973612913622795361319126
5192271236691357619129223613
Example 3
INPUT:
M = 11
N=5
OUTPUT:
MATRIX SIZE OUT OF RANGE.
Solution
import java.util.Scanner;
int m = in.nextInt();
int n = in.nextInt();
if (m <= 2
|| m >= 10
|| n <= 2
|| n >= 10) {
a[i][j] = in.nextInt();
System.out.println("ORIGINAL MATRIX");
System.out.println();
int t = a[i][k];
a[i][k] = a[i][k+1];
a[i][k+1] = t;
}
System.out.println("MATRIX AFTER SORTING ROWS");
System.out.println();
Output
String Program:
Question 1
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 and are in UPPER CASE.
1. Check for the validity of the accepted sentence only for the terminating character.
2. Arrange the words in ascending order of their length. If two or more words have the same
length, then sort them alphabetically.
Test your program for the following data and some random data:
Example 1:
INPUT:
AS YOU SOW SO SHALL YOU REAP.
OUTPUT:
AS YOU SOW SO SHALL YOU REAP.
AS SO SOW YOU YOU REAP SHALL
Example 2:
INPUT:
SELF HELP IS THE BEST HELP.
OUTPUT:
SELF HELP IS THE BEST HELP.
IS THE BEST HELP HELP SELF
Example 3:
INPUT:
BE KIND TO OTHERS.
OUTPUT:
BE KIND TO OTHERS.
BE TO KIND OTHERS
Example 4:
INPUT:
NOTHING IS IMPOSSIBLE#
OUTPUT:
INVALID INPUT
Solution
import java.util.*;
strArr[i] = st.nextToken();
String t = strArr[j];
strArr[j] = strArr[j+1];
strArr[j+1] = t;
}
if (strArr[j].length() == strArr[j + 1].length()
String t = strArr[j];
strArr[j] = strArr[j+1];
strArr[j+1] = t;
sb.append(strArr[i]);
sb.append(" ");
/*
*/
return sb.toString().trim();
System.out.println("Enter a sentence:");
System.out.println();
if (str.charAt(len - 1) != '.'
&& str.charAt(len - 1) != '?'
System.out.println("INVALID INPUT");
return;
/*
*/
System.out.println(str);
System.out.println(sortedStr);
Output
Question 2
ROT13
A/a B/b C/c D/d E/e F/f G/g H/h I/i J/j K/k L/l M/m
↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕
N/n O/o P/p Q/q R/r S/s T/t U/u V/v W/w X/x Y/y Z/z
Write a program to accept a plain text of length L, where L must be greater than 3 and less than 100.
Test your program with the sample data and some random data.
Example 1
INPUT:
Hello! How are you?
OUTPUT:
The cipher text is:
Uryyb! Ubj ner lbh?
Example 2
INPUT:
Encryption helps to secure data.
OUTPUT:
The cipher text is:
Rapelcgvba urycf gb frpher qngn.
Example 3
INPUT:
You
OUTPUT:
INVALID LENGTH
Solution
import java.util.Scanner;
System.out.println("INVALID LENGTH");
return;
char ch = str.charAt(i);
if ((ch >= 'A' && ch <= 'M') || (ch >= 'a' && ch <= 'm')) {
sb.append((char)(ch + 13));
else if ((ch >= 'N' && ch <= 'Z') || (ch >= 'n' && ch <= 'z')) {
sb.append((char)(ch - 13));
else {
sb.append(ch);
System.out.println(cipher);
Output
Q3. 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.
Test your program with the sample data and some random data:
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 VOWEL = 0
LOOK BEFORE YOU LEAP
Example 4
INPUT:
HOW ARE YOU@
OUTPUT:
INVALID INPUT
Solution
import java.util.*;
if (lastChar != '.'
System.out.println("INVALID INPUT");
return;
int c = 0;
while (st.hasMoreTokens()) {
if (isVowel(word.charAt(0))
c++;
sbVowel.append(word);
sbVowel.append(" ");
else {
sb.append(word);
sb.append(" ");
}
String newStr = sbVowel.toString() + sb.toString();
System.out.println(newStr);
ch = Character.toUpperCase(ch);
if (ch == 'A'
|| ch == 'E'
|| ch == 'I'
|| ch == 'O'
|| ch == 'U')
ret = true;
return ret;
Output
Question 4
The names of the teams participating in a competition should be displayed on a banner vertically, to
accommodate as many teams as possible in a single banner. Design a program to accept the names
of N teams, where 2 < N < 9 and display them in vertical order, side by side with a horizontal tab (i.e.
eight spaces).
Test your program for the following data and some random data:
Example 1
INPUT:
N=3
Team 1: Emus
Team 2: Road Rols
Team 3: Coyote
OUTPUT:
E R C
m o o
u a y
s d o
t
R e
o
l
s
Example 2
INPUT:
N=4
Team 1: Royal
Team 2: Mars
Team 3: De Rose
Team 4: Kings
OUTPUT:
R M D K
o a e i
y r n
a s R g
l o s
s
e
Example 3
INPUT:
N = 10
OUTPUT:
INVALID INPUT
Solution
import java.util.Scanner;
int n = in.nextInt();
in.nextLine();
if (n <= 2 || n >= 9) {
System.out.println("INVALID INPUT");
return;
int highLen = 0;
teams[i] = in.nextLine();
highLen = teams[i].length();
if (i >= len) {
System.out.print(" \t");
else {
System.out.print(teams[j].charAt(i) + "\t");
}
System.out.println();
Output
Question 5
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 and are in uppercase.
(b) Convert the non-palindrome words of the sentence into palindrome words by concatenating the
word by its reverse (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 becomes HELPLEH.
Note: The words which end with repeated alphabets, for example ABB would become ABBA and not
ABBBA and XAZZZ becomes XAZZZAX.
[Palindrome word: Spells same from either side. Example: DAD, MADAM etc.]
(c) Display the original sentence along with the 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 BIRDRIB ISI FLYINGNIYLF
Example 2
INPUT:
IS THE WATER LEVEL RISING?
OUTPUT:
IS THE WATER LEVEL RISING?
ISI THEHT WATERETAW LEVEL RISINGNISIR
Example 3
INPUT:
THIS MOBILE APP LOOKS FINE.
OUTPUT:
THIS MOBILE APP LOOKS FINE.
THISIHT MOBILELIBOM APPA LOOKSKOOL FINENIF
Example 3
INPUT:
YOU MUST BE CRAZY#
OUTPUT:
INVALID INPUT
Solution
import java.util.*;
palin = false;
break;
}
return palin;
int i = len - 1;
i--;
sb.append(word.charAt(j));
return sb.toString();
if (lastChar != '.'
System.out.println("INVALID INPUT");
return;
}
while (st.hasMoreTokens()) {
if (isPalinWord) {
sb.append(word);
else {
sb.append(palinWord);
sb.append(" ");
System.out.println();
System.out.println(ipStr);
System.out.println(convertedStr);
Output
Questions:
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:
(1) 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.
Example 2
INPUT : God is great.
OUTPUT:
God Is Great
Word Vowels Consonants
God 1 2
Is 1 1
Great 2 3
Example 3
INPUT: All the best!
OUTPUT:
Invalid Input.