HAY THANK FOR VISIT
Question:-Store the name of 10 countries and tgheir correspoinding capital in turn reaspectively . input the name of the country and search.
import java.util.*;
class Country
{
void main()
{
Scanner sc=new Scanner(System.in);
String name[]={"india","pakistan","afganistan","australia","canada","germany","france","nepal","iran","iraq"};
String cap[]={"new delhi","Islamabad","kabul","canberra","ottawa","berlin","paris","kathmandu","tehran","baghdad"};
System.out.println("entre the name of country");
String n=sc.nextLine();
n=n.toLowerCase();
for(int i=0;i<10;i++)
{
if(n.equals(name[i]))
{
System.out.println(n+"="+cap[i]);
}
}
}
}
Question:-Store the name of 10 countries and tgheir correspoinding capital in turn reaspectively . input the name of the country and search.
import java.util.*;
class Country
{
void main()
{
Scanner sc=new Scanner(System.in);
String name[]={"india","pakistan","afganistan","australia","canada","germany","france","nepal","iran","iraq"};
String cap[]={"new delhi","Islamabad","kabul","canberra","ottawa","berlin","paris","kathmandu","tehran","baghdad"};
System.out.println("entre the name of country");
String n=sc.nextLine();
n=n.toLowerCase();
for(int i=0;i<10;i++)
{
if(n.equals(name[i]))
{
System.out.println(n+"="+cap[i]);
}
}
}
}
No comments:
Post a Comment
HAY THAKYOU FOE VISIT