Exercises to practice your C++ skills

  1. Read in a series of numbers as integers. Ensure they are between 0 and 9 before converting to a character and writing to another array.

  2. Simulate a car park control system. Cars entering are indicated by pressing the letter 'e', cars leaving by entering 'l'. The car park has a limited capacity and must display a full sign when reached - at this point cars can no longer enter. The full sign will only go out when the car park is 95% full.

  3. Write a function to display a count down at the bottom right hand corner of the screen. The function should be able count down from any starting number supplied by the user. Make sure you collect the starting value in main and pass this value to the function for processing.

  4. Simulate a vending register. The program must display the price of a product. It then takes in a series of coins from the user, the value of the coin being represented by 1, 5, 10, 20, 50 or 100, with an entry of 0 indicating that no more coins will be provided. After each coin is entered calculate the amount of money still owed and display this on the screen. If the user has paid too much display the amount of change they are due.

  5. Write a routine to read in a temperature, check that it is at most a six digit number with two decimal places (i.e. largest acceptable is 9999.99) before returning the value as a float.

  6. Write a temperature control systems that will read in a series of floating point values - each entry being at most 9999.99. When the value 0000.00 is entered calculate the average temperature and exit.

  7. Wigginthorpe has an underground railway whose fare structure is based around the number of stations passed through. For every stop passed they are charged 10p. Write a system that will ask where a passenger gets on and off and calculate the charge due. The following stops are available:

Stop Number   Name
1 Bacon Street
2 Wellington
3 Slope
4 Charrington Square
5 Queens Happy
6 Kennington
7 Wombledon
8 Brooks
9 Charterwell
10 Avonside