Exp.
Name: Write a Java program that uses functions to perform the following
[Link]: 15 Date: 2022-06-15
ID: 20095A0363
Page No:
operations:
Aim:
Write a Java program that uses functions to perform the following operations:
ii) Deleting n characters from a given position in a given string.
Source Code:
[Link]
import [Link].*;
import [Link].*;
public class RemoveCharN {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter the String: ");
String str = [Link]();
Scanner sc1 = new Scanner([Link]);
[Link]("Enter the no. of characters to be deleted: ");
int index = [Link]();
Scanner sc2 = new Scanner([Link]);
[Link]("Enter the position: ");
int index1 = [Link]();
[Link](charRemoveAt(str, index, index1));
Rajeev Gandhi Memorial College of Engineering and Technology (Autonomous) 2019-2023-MECH-FDH
}
public static String charRemoveAt(String str, int n, int p) {
return [Link](0, p) + [Link](p + n + 1);
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
Enter the String: coding
Enter the no. of characters to be deleted: 1
Enter the position: 1
cing