We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c1822a commit dfb994dCopy full SHA for dfb994d
1 file changed
GeeksForGeeks/replacepi.java
@@ -0,0 +1,26 @@
1
+//replacing pi with 3.14
2
+
3
+public class replacepi {
4
+ //Here we search the characterand if it match we change
5
+ public static String pi(String str) {
6
+ if(str.length()<2){
7
+ return str;
8
+ }
9
+ else{
10
+ String firsttwo=str.substring(0, 2);
11
+ if(firsttwo.equals("pi")){
12
+ return "3.14"+pi(str.substring(2));
13
14
15
+ return str.charAt(0)+pi(str.substring(1));
16
17
18
19
20
21
+ public static void main(String[] args) {
22
+ String str="xpix";
23
+ String ans=pi(str);
24
+ System.out.println(ans);
25
26
+}
0 commit comments