Skip to main content

Algorithm Analysis and Design Concepts Hands-On | Replace Character

 Algorithm Analysis and Design Concepts

 Hands-On

 Replace Character

String – Replace Characters 

Write a recursive function 'public static String replace(String str,char from,char to) ' that changes all occurrences of 'from' in ‘str’ to ‘to’.

For example, if str were "codebook", and from = 'o' and to = 'e', then, str would become "cedebeek".

Function Definitions:

public static String replace(String str, char from, char to)


Problem Requirements:

Keyword

Min Count

Max Count

for

0

0

while

0

0

 

Note: 
Create the main() inside the class 'ReplaceDriver'

Refer sample input and output for formatting specifications.


Sample Input and Output :

Enter the string

Asia

Enter the character to be replaced

a

Enter the character to be replaced with

i

The modified string is Asii

Algorithm Analysis and Design Concepts   Hands-On   Replace Character  String – Replace Characters   Write a recursive function 'public static String replace(String str,char from,char to) ' that changes all occurrences of 'from' in ‘str’ to ‘to’.  For example, if str were "codebook", and from = 'o' and to = 'e', then, str would become "cedebeek".   Function Definitions:  public static String replace(String str, char from, char to)    Problem Requirements:  Keyword  Min Count  Max Count  for  0  0  while  0  0     Note: Create the main() inside the class 'ReplaceDriver'  Refer sample input and output for formatting specifications.   Sample Input and Output :   Enter the string  Asia  Enter the character to be replaced  a  Enter the character to be replaced with  i  The modified string is Asii      Evaluation Result:     Result Description Summary of tests  *Note: All the test cases might not have same weightage +------------------------------+ |  8 tests run/ 8 tests passed | +------------------------------+   Accenture 2022 Pre Learning 2023

Evaluation Result:


 

Result Description

Summary of tests
*Note: All the test cases might not have same weightage
+------------------------------+
|  8 tests run/ 8 tests passed |
+------------------------------+
 

Comments

Subscribe to Get's Answer by Email