You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Write a program to enter 10 countries and capitals into two single dimensional arrays. Enter the value of a country and print its corresponding capital.
12/02/24
*/
importjava.util.Scanner;
publicclassProgram20 {
publicstaticvoidmain(String[] args) {
Scannersc = newScanner(System.in);
Stringcountries[] = newString[10], country;
Stringcapitals[] = newString[10];
inti;
booleanflag = false;
for (i = 0; i < 10; i++) {
System.out.print("Enter a country: ");
countries[i] = sc.next();
System.out.print("Enter its capital: ");
capitals[i] = sc.next();
}
System.out.print("Enter the country to search for: ");