-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountry.java
More file actions
54 lines (43 loc) · 2.7 KB
/
Country.java
File metadata and controls
54 lines (43 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package Homework;
import java.util.Scanner;
public class Country {
public static void main(String[] args) {
// Разработайте алгоритм, который будет получать значение населения того или иного города,
// а так же идентификатора страны и определять насколько большой город в зависимости от страны.
// Например, для Германии город с населением до 100к человек маленький, до 400к человек средний,
// больше 1кк человек - большой.
// Для Франции, до 200к маленький, до 500к - средний, более 1.5кк - большой.
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a population: ");
int population = scanner.nextInt();
System.out.print("Enter an country identifier: ");
String countryId = scanner.next(); // FR, DE
if (countryId.equals("DE")) {
if (population > 0 && population < 100_000)
System.out.println("this city is small town in Germany");
else if (population >= 100_000 && population < 400_000)
System.out.println("this city is middle town in Germany");
else if (population >= 400_000 && population < 1_000_000)
System.out.println("this city in Germany with undefined parameter");
else if (population >= 1_000_000)
System.out.println("this city is big town in Germany");
else
System.out.println("wrong information about population");
} else if (countryId.equals("FR")) {
// Для Франции, до 200к маленький, до 500к - средний, более 1.5кк - большой.
if (population > 0 && population < 200_000)
System.out.println("this city is small town in France");
else if (population >= 200_000 && population < 500_000)
System.out.println("this city is middle town in France");
else if (population >= 400_000 && population < 1_000_000)
System.out.println("this city in France with undefined parameter");
else if (population >= 1_500_000)
System.out.println("this city is big town in France");
else
System.out.println("wrong information about population");
} else {
System.out.println("wrong country id");
}
scanner.close();
}
}