Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
8.5k views
in Computer by (49.9k points)
closed by

Input a word in uppercase and check for the position of the first occurring vowel and perform the following operation.

(i) Words that begin with a vowel are concatenated with “Y”. 

For example, EUROPE becomes EUROPEY. 

(ii) 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 of the vowel and is concatenated by “C”. 

For example, PROJECT becomes OJECTPRC.

(iii) Words which 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 UPPER CASE 

void convert (): converts the word into its changed form and stores it in string Cxt 

void display(): displays the original and the changed word 

Specify the class Rearrange giving the details of the constructor (), void readword ( ), void convert () and void display (). 

Define a main () function to create an object and call the function accordingly to enable the task.

1 Answer

+1 vote
by (49.0k points)
selected by
 
Best answer

import java.io.*; 

class Rearrange 

String Txt; 

String Cxt; 

intLen; 

public Rearrange () 

Txt= " ''; 

Cxt = '' " ; 

Len = 0; 

public void readword () 

{

BufferedReader br = new BufferedReaderfnew 

InputStreamReader(Systemin)): 

System.out.println( "Enter the String"); 

Txt = br. readLinef); 

public void convert)) 

String str1 = " ", str 2 = " " ; 

boolean check = false; 

char ch1, ch2, ch3;

ch1 = Txt char A+(0); 

if (ch1 == 'A' || ch1 == 'E' || ch1 == T || ch1 == 'O' || ch1 == 'U') 

{

Cxt = Txt + "Y''; 

else 

for (i = 0; i < Txt. length (); i ++) 

ch2 = TxtcharAt (i); if(ch2 ! = 'A' || ch2 ! = 'E' || ch2 ! = 'I' || ch2 ! = 'O' || ch2 ! = 'U') 

Strl = str1 + ch2; 

else

check = true; 

for (j = i; j < Txt.length 0; j++) 

ch3 = Txt.charAt (j); 

str2 = str2 + ch3 ; 

Str2 = Str2 + "C"; 

Cxt=Str2 + Str1; 

if (found = = false) 

Cxt = Txt + "N"; 

}

public void display() 

System.out.println("The original string is" + Txt); 

System.out.println(" The new String is"+ Cxt); 

public void main() 

Rearrange obj = new Rearrange() 

obj.readword( ); 

obj.convert( ); 

obj.display(); 

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...