This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
start [2011/05/10 11:27] kel |
start [2011/05/10 11:30] kel |
||
---|---|---|---|
Line 79: | Line 79: | ||
Use flow charts or N-S charts to elegantly solve the following algorithms. Some are harder than others... Try actually coding it after doing the brainwork. | Use flow charts or N-S charts to elegantly solve the following algorithms. Some are harder than others... Try actually coding it after doing the brainwork. | ||
-- | -- | ||
+ | |||
Round any decimal number UP to the next highest multiple of 0.25. | Round any decimal number UP to the next highest multiple of 0.25. | ||
+ | |||
-- | -- | ||
+ | |||
Convert any Roman number to decimal (e.g. MCMLXIX to 1969) - and/or vice versa | Convert any Roman number to decimal (e.g. MCMLXIX to 1969) - and/or vice versa | ||
+ | |||
-- | -- | ||
+ | |||
Convert any binary number to decimal. | Convert any binary number to decimal. | ||
+ | |||
-- | -- | ||
+ | |||
Find the lowest (or greatest) common denominator of 2 integers (or report that there is no LCD or GCD). | Find the lowest (or greatest) common denominator of 2 integers (or report that there is no LCD or GCD). | ||
+ | |||
-- | -- | ||
+ | |||
List prime numbers up to 100 | List prime numbers up to 100 | ||
+ | |||
-- | -- | ||
+ | |||
Simulate the display of a single-digit liquid crystal display | Simulate the display of a single-digit liquid crystal display | ||
+ | |||
+ | |||
Assume there are 7 LCD bars like this | Assume there are 7 LCD bars like this | ||
+ | |||
_ | _ | ||
|_| | |_| | ||
Line 96: | Line 110: | ||
Feed it any numeral or alphabetic character in hexadecimal range (0 to F) and it should turn on the right bars. (Efficiency is the key requirement here!) | Feed it any numeral or alphabetic character in hexadecimal range (0 to F) and it should turn on the right bars. (Efficiency is the key requirement here!) | ||
+ | |||
-- | -- | ||
+ | |||
Given a price including 10% GST, give the ex-tax price and the tax component, e.g. $11 inc = $10 ex + $1 GST. | Given a price including 10% GST, give the ex-tax price and the tax component, e.g. $11 inc = $10 ex + $1 GST. | ||
+ | |||
-- | -- | ||
+ | |||
Create a virtual deck of cards encoded as numbers 1 to 52. Given any number from 1 to 52, the algorithm should return the suit and rank represented by the card. | Create a virtual deck of cards encoded as numbers 1 to 52. Given any number from 1 to 52, the algorithm should return the suit and rank represented by the card. | ||
+ | |||
-- | -- | ||
Create an algorithm to shuffle the virtual deck of cards | Create an algorithm to shuffle the virtual deck of cards | ||
+ | |||
+ | |||
-- | -- | ||
+ | |||
Create an algorithm to play naughts and crosses - it should be unbeatable if the algorithm plays first. | Create an algorithm to play naughts and crosses - it should be unbeatable if the algorithm plays first. | ||
+ | |||
-- | -- | ||
+ | |||
Given an number of dollars, calculate what notes or coins need to be given as change from $100. e.g. $67 = 1 x $20, 1 x $10, 1 x $2, 1 x $1. | Given an number of dollars, calculate what notes or coins need to be given as change from $100. e.g. $67 = 1 x $20, 1 x $10, 1 x $2, 1 x $1. | ||
+ | |||
-- | -- | ||
+ | |||
An electrical company is developing a new main-powered sensorlight with the following requirements: | An electrical company is developing a new main-powered sensorlight with the following requirements: | ||
+ | |||
• It turns on its LED light for a predetermined time (e.g. 60 seconds) after sensing movement with its passive infrared (PIR) detector. | • It turns on its LED light for a predetermined time (e.g. 60 seconds) after sensing movement with its passive infrared (PIR) detector. | ||
+ | |||
• It does not turn the light on if its light detector senses that the room is already well illuminated (e.g. during the day) | • It does not turn the light on if its light detector senses that the room is already well illuminated (e.g. during the day) | ||
+ | |||
• While its light is on, any further movement detection resets the timer back to its starting value and the countdown starts again. | • While its light is on, any further movement detection resets the timer back to its starting value and the countdown starts again. | ||
+ | |||
Convert your algorithm into a working simulation of the light. You will need to simulate: | Convert your algorithm into a working simulation of the light. You will need to simulate: | ||
+ | |||
• The day/night sensor (e.g. with radio buttons) | • The day/night sensor (e.g. with radio buttons) | ||
+ | |||
• The movement sensor (e.g. with a mouse click or keypress) | • The movement sensor (e.g. with a mouse click or keypress) | ||
+ | |||
• The LED light (e.g. with a shape changing its colour) | • The LED light (e.g. with a shape changing its colour) | ||
+ | |||
Show the value of the countdown time onscreen to verify its behaviour. | Show the value of the countdown time onscreen to verify its behaviour. | ||
+ | |||
----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ||
+ | |||