veronikaaa86

04. Town Info

Sep 21st, 2022
1,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. package dataTypes;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P04TownInfo {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         //Town {town name} has population of {population} and area {area} square km.
  10.         String townName = scanner.nextLine();
  11.         int population = Integer.parseInt(scanner.nextLine());
  12.         short area = Short.parseShort(scanner.nextLine());
  13.  
  14.         String result = String.format
  15.                 ("Town %s has population of %d and area %d square km.",
  16.                         townName, population, area);
  17.  
  18.         System.out.println(result);
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment