
Write a program to store the population of 8 countries. i) Define two arrays to store the names of the countries and their population�s numbers. ii) Write a loop that uses these arrays to print each country�s name and its population.

import java.util.*;
class ArrayExample10
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
String countries[]=new String[8];
double population[]=new double[8];
System.out.println("Enter country names: ");
for(int i=0;i<countries.length;i++){
countries[i]=input.nextLine();
}
System.out.println("Enter country's population: ");
for(int i=0;i<population.length;i++){
population[i]=input.nextDouble();
}
for(int i=0;i<8;i++){
System.out.println(countries[i]+"\t "+population[i]);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.