-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path9.java
More file actions
31 lines (26 loc) · 1.24 KB
/
9.java
File metadata and controls
31 lines (26 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String name,temp,result="";
char in; //in means Initial
System.out.println("Enter your full Name");
name = sc.nextLine(); //name = Sachin Ramesh Tendulkar
temp = name.substring(0, (name.indexOf(" ")-1)); // temp = Starts at '0' and ends at 'first space - 1'.
name = name.substring(name.indexOf(" ") + 1); //name = Ramesh Tendulkar
System.out.println(temp+" |"+name); //Sachi |Ramesh Tendulkar
in = temp.charAt(0); //in = S
result = result.concat(Character.toUpperCase(in) + "."); // result = S.
temp = name.substring(0, (name.indexOf(" ")-1)); //temp = Ramesh
name = name.substring(name.indexOf(" ") + 1); //name = Tendulkar
System.out.println(temp+" |"+name); //Rame |Tendulkar
in= temp.charAt(0);
result = result.concat(Character.toUpperCase(in) + "."); // result = S.R.
result = result.concat(name); // result = S.R.Tendulkar
System.out.println(result);
}
}
// This program uses methods like substring, indexOf, charAt, concat, toUpperCase, etc.