Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Now, the above call to insert, i.e., insert( chArray, s,k ) will look for ' e ' in the string s. There is an 'e'

image text in transcribedimage text in transcribed

Now, the above call to insert, i.e., insert( chArray, s,k ) will look for ' e ' in the string s. There is an 'e' at the index location 1 in s. Therefore, the function insert will return a string containing "eelpo" by inserting the value of variable c at the location just before where there is a match of 'e' found in the string s. If no such match is found then the value of c will be appended in s at the end. String s="Helpo"; char c = 'z'; char [] chArray =new char[s.length()+2]; println(insert( chArray, s, c)); will print Helpoz. Write a program having a function insert that accepts a char array, named chArray, a string named s, and a char named chr. The function insert will find the value of the chr in the s. If the value is found the function insert will insert the character in the s just before the one found. If there is no character found then the value of chr will be inserted in the end of the String s. HINT: Because String in processing does not allow inserting a character at a particular index location (though you may read a character value within a string using the function charAt), therefore, you may exploit the array passed to the function insert. Make sure the array has enough room to keep all data you want to insert temporarily. The function insert will return a string, filled with the data in the chArray. For example, Let, String s="Helpo"; char c = 'e'; char [] chArray =new char[s.length()+2]; println(insert( chArray, s, c )); Now, the above call to insert, i.e., insert( chArray, s,k ) will look for 'e' in the string s. There is an 'e' at the index location 1 in s. Therefore, the function insert will return a string containing "eelpo" by inserting the value of variable c at the location just before where there is a match of ' e ' found in the string s. If no such match is found

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

What is American Polity and Governance ?

Answered: 1 week ago

Question

2. What are the different types of networks?

Answered: 1 week ago