emodev

Untitled

Nov 21st, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package StringAndTextProcessing.MoreExercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class a_ExtractPersonInfo {
  6.     public static void main(String[] args) {
  7.         Scanner console = new Scanner(System.in);
  8.         int numberLines = Integer.parseInt(console.nextLine());
  9.  
  10.         for (int i = 0; i < numberLines; i++) {
  11.             String line = console.nextLine();
  12.  
  13.             int firstSymbol = line.indexOf("@") + 1;
  14.            int lastSymbol = line.indexOf("|");
  15.            String name = line.substring(firstSymbol, lastSymbol);
  16.  
  17.            firstSymbol = line.indexOf("#");
  18.            lastSymbol = line.indexOf("*");
  19.            line = line.substring(firstSymbol+1, lastSymbol);
  20.  
  21.             System.out.println(name + " is " + line + " years old.");
  22.         }
  23.     }
  24. }
Add Comment
Please, Sign In to add comment