/
CountriesApp.java
37 lines (28 loc) · 963 Bytes
/
CountriesApp.java
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
import java.io.IOException;
import java.util.Scanner;
public class CountriesApp {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
System.out.println("Welcome to the Countries Maintenance Application!");
int response = 1;
do {
System.out.println("1 - See the list of countries" + "\n" + "2 - Add a country" + "\n" + "3 - Exit");
int choice = scan.nextInt();
if (choice == 1) {
// print list of countries
CountriesTextFile listOfCountries = new CountriesTextFile();
listOfCountries.readCountries();
}
if (choice == 2) {
System.out.print("Enter country: ");
String addition = scan.next();
CountriesTextFile listOfCountries = new
CountriesTextFile();
listOfCountries.addCountry(addition);
System.out.println("The country has been saved!");
// add a country
}
} while (response != 3);
System.out.println("Buh-bye!");
}
}