Posts

Showing posts with the label string program in java

Encrypt Program ISC Specimen 2023 Theory

A class Encrypt has been defined to replace only the vowels in a word by the next corresponding vowel and forms a new word, i.e. A → E, E  → I, I  → O, O  → U and U  → A. Example : Input: COMPUTER Output: CUMPATIR Some of the members of the class are given below: Class name : Encrypt Data members/instance variables : wrd: to store a word len: integer to store the length of the word newWrd: to store the encrypted word Methods/Member functions : Encrypt(): default constructor to initialize data members with legal initial values void acceptWord(): to accept a word in uppercase void freqVowCon(): finds the frequency of the vowels void nextVowel(): replaces only the vowels from the word stored in 'wrd' by the next corresponding vowel and assigns it to 'newWrd', with the remaining alphabets unchanged void disp(): displays the original word along with the encrypted word Specify the class Encrypt giving details of the constructor, void acceptWord(), void freqVowCon(), void ...

Common Words ISC Computer Science 2021 Practical

Write a program to accept a paragraph containing two sentences only. The sentences may be terminated by either '.', '?' or '!' only. Any other character may be ignored. The words are to be separated by a single blank space and must be in uppercase. Perform the following tasks: (a) Check for the validity of the accepted paragraph for the number of sentences and for the terminating character. (b) Separate the two sentences from the paragraph and find the common words in the two sentences with their frequency of occurrence in the paragraph. (c) Display both the sentences separately along with the common words and their frequency, in the format given below. Test your program for the following data and some random data: Example 1 : INPUT: IS IT RAINING? YOU MAY GET WET IF IT IS RAINING. OUTPUT: IS IT RAINING? YOU MAY GET WET IF IT IS RAINING. COMMON WORDS FREQUENCY IS 2 IT 2 RAINING 2 Example 2 : INPUT: INDIA IS MY MOTHERLAND AND I AM PROUD OF MY MOTH...

Banner Program ISC Computer Science 2018 Practical

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 r R g l s o s s e Example 3: INPUT: N = 10 OUTPUT: INVALID INPUT import java.util.Scanner; class Banner{     public static void main(String[] arg...

Capital Word ISC Computer Science 2018 Theory

A class Capital has been defined to check whether a sentence has words beginning with a capital letter or not. Some of the members of the class are given below: Class name : Capital Data members/instance variables : sent: to store a sentence freq: stores the frequency of words beginning with a capital letter Member functions/methods : Capital(): default constructor void input(): to accept the sentence boolean isCap(String w): checks and returns true if word begins with a capital letter, otherwise returns false void display(): displays the sentence along with the frequency of the words beginning with a capital letter Specify the class Capital, giving details of the constructor, void input(), boolean isCap(String) and void display(). Define the main() function to create an object and call the functions accordingly to enable the task. import java.util.Scanner; import java.util.StringTokenizer; class Capital{     String sent;     int freq;     public Capital(...

Convert to Palindrome ISC Computer Science 2019 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 and are in uppercase. Perform the following tasks: (a) Check for the validity of the accepted sentence. (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 words: 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...

Rearrange Vowels ISC Computer Science 2019 Theory

A class Rearrange has been defined to modify a word by bringing all the vowels in the word at the beginning followed by consonants. Example : ORIGINAL becomes OIIARGNL Some of the members of the class are given below: Class name : Rearrange Data members/instance variables : wrd: to store a word newwrd: to store the rearranged word Member functions/methods : Rearrange(): default constructor void readWord(): to accept the word in uppercase void frequency(): finds the frequency of vowels and consonants in the word and displays them with an appropriate message void arrange(): rearranges the word by bringing the vowels at the beginning followed by consonants void display(): displays the original word along with the rearranged word Specify the class Rearrange, giving details of the constructor, void readWord(), void frequency(), void arrange() and void display(). Define the main() function to create an object and call the functions accordingly to enable the task. import java.util.Scanner; ...

No Repeat Program ISC Computer Science 2022 Semester 2 Theory

Design a class NoRepeat which checks whether a word has no repeated alphabets in it. Example : COMPUTER has no repeated alphabets but SCIENCE has repeated alphabets. The details of the class are given below: Class name : NoRepeat Data members/instance variables : word: to store the word len: to store the length of the word Methods/Member functions : NoRepeat(String wd): parameterized constructor to initialize word = wd boolean check(): checks whether a word has no repeated alphabets and returns true else returns false void prn(): displays the word along with an appropriate message Specify the class NoRepeat, giving details of the constructor, boolean check() and void prn(). Define the main() function to create an object and call the functions accordingly to enable the task. import java.util.Scanner; class NoRepeat{     String word;     int len;     public NoRepeat(String wd){         word = wd;         len = word.le...

Arrange Words ISC Computer Science 2020 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 and are in uppercase. Perform the following tasks: (a) Check for the validity of the accepted sentence only for the terminating character. (b) Arrange the words in ascending order of their length. If two or more words have the same length, then sort them alphabetically. (c) Display the original sentence along with the converted sentence. 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 import java.util.Scanner; import java.util.StringToke...

Mix Words ISC Computer Science 2020 Theory

A class Mix has been defined to mix two words, character by character, in the following manner: The first character of the first word is followed by the first character of the second word and so on. If the words are of different length, the remaining characters of the longer word are put at the end. Example : If the first word in "JUMP" and the second word is "STROLL", then the required word will be "JSUTMRPOLL". Some of the members of the class are given below: Class name : Mix Data members/instance variables : wrd: to store a word len: to store the length of the word Member functions/methods : Mix(): default constructor to initialize the data members with legal initial values void feedWord(): to accept the word in uppercase void mixWord(Mix p, Mix q): mixes the words of objects p and q as stated above and stores the resultant word in the current object void display(): displays the word Specify the class Mix giving details of the constructor, void feedWo...

Rearrange Word ISC Computer Science 2010 Theory

Input a word in uppercase and check for the position of the first occurring vowel and perform the following operations: Words that begin with a vowel are concatenated with "Y". For example, EUROPE becomes EUROPEY. Words that contain a vowel in-between should have the first part from the position of the vowel till the end, followed by the part of the string from beginning till the position before the vowel and is concatenated by "C". For example, PROJECT becomes OJECTPRC. Words that do not contain a vowel are concatenated with "N". For example, SKY becomes SKYN. Design a class Rearrange using the description of the data members and member functions given below: Class name : Rearrange Data members/instance variables : txt: to store a word. cxt: to store the rearranged word. len: to store the length of the word. Member functions : Rearrange(): constructor to initialize the instance variables. void readWord(): to accept the word input in uppercase. void conver...