Advertisement
veronikaaa86

06. Concatenate Data

May 13th, 2023
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ConcatenateData {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         //You are <firstName> <lastName>, a <age>-years old person from <town>.
  10.  
  11.         String firstName = scanner.nextLine();
  12.         String lastName = scanner.nextLine();
  13.         int age = Integer.parseInt(scanner.nextLine());
  14.         String town = scanner.nextLine();
  15.  
  16.         System.out.printf("You are %s %s, a %d-years old person from %s.%n", firstName, lastName, age, town);
  17.  
  18.         // String -> %s
  19.         // int -> %d
  20.         // double -> %f
  21.         // char -> %c
  22.         // new line -> %n
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement