myrdok123

06. Concatenate Data

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