Computer Science, asked by alwin2006janson, 6 months ago

Given the list of 5 countries and their respective currencies into two

arrays. Develop a program to accept the name of a country as

argument and print the corresponding currency as output.

The program should give an error message when a country’s name

is not in the list. [15]

Given:

Country [ ] = {“India”,”China”, “UAE”, “Japan”, “Britain”};

Currency [ ] = {“Rupee”, “Yaan”, “Dirham”, “Yen”, “Pounds”};

Input : Japan

Output : Yen​

Answers

Answered by jayp64928
0

Answer:

Given the list of 5 countries and their respective currencies into two

arrays. Develop a program to accept the name of a country as

argument and print the corresponding currency as output.

The program should give an error message when a country’s name

is not in the list. [15]

Given:

Country [ ] = {“India”,”China”, “UAE”, “Japan”, “Britain”};

Currency [ ] = {“Rupee”, “Yaan”, “Dirham”, “Yen”, “Pounds”};

Input : Japan

Output : Yen

Answered by sujitharajan
2

Answer:

class country

{

public void accept(String s)

{

String country[]={"India","China","UAE","Japan","Britain"};

int l=country.length;

String currency[]={"ruppes","yaan","Dirham","yen","Pound"};

int i,flag=0;

for(i=0;i<l;i++)

{

if(s.equalsIgnoreCase(country[i]))

{

flag++;

break;

}

}

if(flag==1)

System.out.println(country[i]+"\t\t"+currency[i]);

else

System.out.println("country not present");

}

}

Similar questions