Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hello can this be answered using processing programming language Write a program having a function insert that accepts a char array, named chArray, a string

hello can this be answered using processing programming language
image text in transcribed
image text in transcribed
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]; 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

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

Step: 3

blur-text-image

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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago