Advertisement
myrdok123

06. Concatenate Data

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