Small Basic Exercise: European Capitals


Here's a special exercise to try out! See if you can do it, and head to the forum if you have any questions!

    

Write a program that provides a review of selected European countries and their capitals. Create an array that associates a country’s name with its capital like this:

capital["Netherlands"] = "Amsterdam"

capital["Greece"]        = "Athens"

capital["Serbia"]         = "Belgrade"

capital["Germany"]     = "Berlin"

    

Include this data:

Belgium (Brussels); France (Paris); Germany (Berlin); Greece (Athens);
Ireland (Dublin); Italy (Rome); Poland (Warsaw); Portugal (Lisbon); Spain
(Madrid); United Kingdom (London)

  

Have your program prompt the user to enter the name of a country and then show her its capital like in the following sample run:

Enter the name of a European country: France

The capital of France is Paris

 

Enter the name of a European country: Germany

The capital of Germany is Berlin

  

Enter the name of a European country: Japan

Sorry, I don't know this

    

Next, update your program so that your user can enter the capital and get the country instead!

 

Do you have any questions? Ask us! We're full of answers and other fine things!

Head to the Small Basic forum to get the most answers to your questions: 

http://social.msdn.microsoft.com/Forums/en-US/smallbasic/threads/   

And go to http://blogs.msdn.com/SmallBasic to download Small Basic and learn all about it!

   

Small and Basically yours,

   - Ninja Ed & Majed Marji

 

Comments (1)

Skip to main content