Strings

Java : Strings Program List




Program [1]

Java program to enter a sentence and print the words which starting with a vowel


View Solution


Program [2]

Write a Java Program to Swap first and last character of each words in a Sentence .

Example:

Input: infomax computer academy

Output: xnfomai romputec ycadema



View Solution


Program [3]

Java program to remove duplicate character from string

Sample:

Input: infomaxcomputeracademy

Output:  infomaxcputerdy


View Solution


Program [4]

java to swap first character of each word with next character


View Solution


Program [5]

Write a Java Program to check input string is Palindrome or Not.

Sample 1:

Input: nitin

Output: Entered string is a palindrome.


Sample 2:

Input: infomax

Output: Entered string is not a palindrome.



View Solution


Program [6]

Write a Java program to from a new word by extracting the first letter of each word in the entered sentence.


View Solution


Program [7]

Write a Program to convert first letter of each word in a sentence to uppercase and the remaining letters to lowercase.

Sample:

Input: InfoMax ComuTar aCadeMy

Output: Infomax Comutar Academy


View Solution


Program [8]

One of the system of calculating word value is Hebrew Numerology, in which corresponding numeric value of letter (1 to 26 for A to Z) are joined together. A “Happy Word” is a word whose eventual sum of square of the digits of its word value is equal to 1. Write a program to input a word and check whether it is a Happy Word or not. The program displays a message accordingly.

Sample Input: VAT

Place value V=22, A=1, T=20

[Hint A=1,b=2,.............................Z=26]

Solution: 22120 => 2^2+2^2+1^2+2^2+0=13 =>1^2+3^2=10 => 1^2+0=1

Sample Output: A Happy Word



View Solution


Program [9]

Pangram :- If a string contains every letter of the English alphabet i.e all 26 alphabets then the string is known as Pangram.

For Example :-

String1 = The quick brown fox jumps over the lazy dog

So as we can see that the given strings contains all letters of English alphabet therefore the string is Pangram.


View Solution


Program [10]

The potential of a word is found by adding the ASCII value of the alphabets.

(ASCII values of A to Z are 65 to 90).

Example: BALL

Potential = 66 + 65 + 76 + 76 = 283

Write a program to accept a sentence which may be terminated by either “ . ” , “ ? ” or “ ! ” only. The words of sentence are separated by single blank space and are in UPPER CASE. Decode the words according to their potential and arrange them in ascending order of their potential strength.

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

Example 1:

INPUT: HOW DO YOU DO?

OUTPUT: HOW = 238

DO = 147

YOU = 253

DO = 147

DO DO HOW YOU

Example 2:

INPUT: LOOK BEFORE YOU LEAP.

OUTPUT: LOOK = 309

BEFORE = 435

YOU = 253

LEAP = 290

YOU LEAP LOOK BEFORE

Example 3:

INPUT: HOW ARE YOU#

OUTPUT: INVALID INPUT


View Solution


Program [11]

Write a program to input a string in uppercase and print the frequency of each character.

Example:

INPUT : COMPUTER HARDWARE

OUTPUT:

CHARACTER FREQUENCY

A 2

C 1

D 1

E 2

H 1

M 1

O 1

P 1

R 3

T 1

U 1

W 1



View Solution


Program [12]

Write a program to accept a string. Convert the string to uppercase. Count and output the number of double letter sequences that exist in the string.


Example:


Input : SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLLE

Output: 4


View Solution


Program [13]

Write a program that encodes a word into Piglatin. To translate word into a Piglatin word, convert the word into uppercase and then place the first vowel of the original word as the start of the new word along with the remaining alphabets. The alphabets present before the vowel being shifted towards the end followed by “AY”.

Sample 1:

Input  : London,

Output : ONDONLAY

Sample 2:

Input : Olympics,

Output : OLYMPICSAY



View Solution


Program [14]

Write a program to assign a full path and file name as given below. Using library functions, extract and output the file path, file name and file extension separately as shown.

Input C:\Users\admin\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\

File name: flower

Extension: jpg


View Solution


Program [15]

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. Example 1 :

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.

Example 2 :

INPUT: n = 13

OUTPUT: INVALID ENTRY



View Solution


Program [16]

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.

Example 1 :

INPUT: Enter your date of birth in dd mm yyyy format

05

01

2010


OUTPUT: VALID DATE 5

Example 2 :


INPUT: Enter your date of birth in dd mm yyyy format 03

04

2010


OUTPUT: VALID DATE

93

Example 3 :


INPUT: Enter your date of birth in dd mm yyyy format 34

06

2010


OUTPUT: INVALID DATE



View Solution


Program [17]

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.

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




View Solution


Program [18]

A Palindrome is a word that may be read the same way in either direction.

Accept a sentence in UPPER CASE which is terminated by either ” . “, ” ? ” or ” ! “. Each word of the sentence is separated by a single blank space.

Perform the following tasks:

(a) Display the count of palindromic words in the sentence.

(b) Display the palindromic words in the sentence. Example of palindromic words:

MADAM, ARORA, NOON

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

Example 1

INPUT : MOM AND DAD ARE COMING AT NOON.

OUTPUT : MOM DAD NOON

NUMBER OF PALINDROMIC WORDS : 3

Example 2

INPUT : NITIN ARORA USES LIRIL SOAP.

OUTPUT : NITIN ARORA LIRIL

NUMBER OF PALINDROMIC WORDS : 3

Example 3

INPUT : HOW ARE YOU?

OUTPUT : NO PALINDROMIC WORDS



View Solution


Program [19]

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

Perform the following tasks:

(a) Accept the sentence and reduce all the extra blank space between two words to a single blank space.

(b) Accept a word from the user which is part of the sentence along with its position number and delete the word and display the sentence.

Test your program with the sample data and some random data



View Solution


Program [20]

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.

OUTPUT : 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.

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.



View Solution


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad