Advertisement
Spocoman

06. Concatenate Data

Aug 21st, 2024
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ConcatenateData {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String firstName = scanner.nextLine();
  7.         String lastName = scanner.nextLine();
  8.         int age = Integer.parseInt(scanner.nextLine());
  9.         String town = scanner.nextLine();
  10.  
  11.         System.out.println("You are " + firstName + ' ' + lastName + ", a " + age + "-years old person from " + town + '.');
  12.     }
  13. }
  14.  
  15. ИЛИ:
  16.  
  17. import java.util.Scanner;
  18.  
  19. public class ConcatenateData {
  20.     public static void main(String[] args) {
  21.         Scanner scanner = new Scanner(System.in);
  22.         String firstName = scanner.nextLine();
  23.         String lastName = scanner.nextLine();
  24.         Integer age = Integer.parseInt(scanner.nextLine());
  25.         String town = scanner.nextLine();
  26.  
  27.         System.out.printf("You are %s %s, a %d-years old person from %s.", firstName, lastName, age, town);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement