Advertisement
desislava_topuzakova

4. Town Info

Jan 21st, 2024
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package DataTypes;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TownInfo_04 {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String townName = scanner.nextLine(); //име на града
  10. //integer types -> byte, short, int, long, BigInteger -> %d
  11. //double types -> double, float -> %f
  12. int population = Integer.parseInt(scanner.nextLine()); //населние на града
  13. short area = Short.parseShort(scanner.nextLine()); //площ на града
  14.  
  15. System.out.printf("Town %s has population of %d and area %d square km.", townName, population, area);
  16. }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement