You are on page 1of 2

Selection Using Switch

1. Write a program that uses a switch statement that takes as input an integer used to
represent a month and output the name of the month. E.g 1, outputs January,12
December.

2. Write a program that will ouput the spoken language when given a country code,
the country codes you can have are UK,US,ES,MX, FR,IT
MX for Mexico, ES for Spain, ,Fr for France, IT for Italy

Please not there will be merging of cases here for the countries that speak English or
Spanish

Example program 7 – Indefinite iteration

Tasks

1. Write a program which keeps on asking the user what the capital of France is

until the user gets it right. The program should then say “Well done!”.

2. Write a program which keeps asking the user the answer to 7 x 7 and says

OK when the user gets it right.

3. Find out how to put the condition at the beginning of the loop and if this makes a
difference.

4. Write a program which asks the user for their favourite band. The only answer
which will allow the loop to end should be “The Beatles”. The program should

then say “I see you have taste”. Every time a band is entered other than “The

Beatles” the message “You must be joking, try again” should be displayed.

5. Write a program which chooses a random number between 1 and 100. The

user has to guess the number. Each time the user guesses they are told

whether they are too high, too low or spot on. When the user has guessed

correctly the message “You’ve done it” should be displayed.

You might also like