Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ChangePI
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.Scanner; class Rextester { private static String changePI (String str) { if (str.length () <= 2) return str.equals ("pi") ? "3.14" : str; return str.substring (0, 2).equals ("pi") ? "3.14".concat ( changePI (str.substring (2)) ) : str.substring (0, 1).concat ( changePI (str.substring (1)) ); } public static void main(String args[]) { Scanner scan = new Scanner (System.in); String [] arr = new String [5]; int i = 0; try { while ( (arr[i] = scan.nextLine ()) != "" ) System.out.println (changePI (arr [i++])); } catch (Exception e) { System.out.println ("no more found!"); } } }
run
|
edit
|
history
|
help
0
1(D).
Implementation of several common methods of LinkedList
Rakibul Haque
Counter.java
ex25
Homework
name
Find Median in Large File of Integers
Switch case example
1.6