repl.it
@AlexLovelock/

Week 5 Private study Task 5

Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    System.out.println("Enter first, middle, and last name");
    String name = input.nextLine();

    int Firstspace = name.indexOf(" ");
    int Secondspace = name.lastIndexOf(" ");
    
    String Initial1  = name.substring (0, 1);
    String Initial2 = name.substring(Firstspace+1, Firstspace+2);
    String Initial3 = name.substring(Secondspace+1, Secondspace+2);

    System.out.println("Hello  " + Initial1 + Initial2 + Initial3);





  }
}