desislava_topuzakova

2. Concatenate Data

Oct 17th, 2021
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ConcatenateData_02 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. //1. прочитаме от конзолата: име
  8. //2. прочитаме от конзолата: фамилия
  9. //3. прочитаме от конзолата: възраст
  10. //4. прочитаме от конзолата: град
  11. //5. отпечатвам: "You are <firstName> <lastName>, a <age>-years old person from <town>."
  12.  
  13. String name = scanner.nextLine();
  14. String lastName = scanner.nextLine();
  15. int age = Integer.parseInt(scanner.nextLine());
  16. String town = scanner.nextLine();
  17.  
  18. //System.out.println("You are " + name + " " + lastName + ", a " + age + "-years old person from " + town + ".");
  19. System.out.printf("You are %s %s, a %d-years old person from %s.", name, lastName, age, town);
  20. }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment