alok singh

alok singh

  • NA
  • 1
  • 2.1k

C++ or Java query

Sep 24 2012 11:36 AM

A country is defined as a Good Country if it has ALL the following properties:

  1. The number of cities should be between 200 to 300.
  2. The country should have nuclear power.
  3. The name of the country should contain the characters 'A' and 'I' but should not contain 'R'. (Assume case insensitive matching)
  4. The length of the country's name should be greater than or equal to 5.
  5. The name of the continent to which the country belongs should be "Asia" or "Africa"
  6. The country should have atleast 3 neighbouring countries none of which should end with the word "tan".
  7. If the country does not have any neighbouring countries, then the name of the country must match the name of the continent it is in.

Write a method: 

boolean isGoodCountry(String countryName, int numCities, int numVillages, boolean hasNuclearPower, String continentName, String[] neighborCountries)

countryName     Name of the country.
numCities     number of cities in the country.
numVillages     number of villages in the country.
hasNuclearPower     whether or not the country has nuclear power.
continentName     Name of the continent the country is situated in.
neighborCountries     an array containing the names of the neighboring countries.


Answers (1)