Current course
Participants
Topic outline
Introduction
Programming is a significant aspect of the A Level course and in addition to knowing the theory you must be able to apply the tools and techniques appropriately. The questions you will encounter in the AS F452 exam are short but the programming project in F454 is an extended and complex programming task.The purpose of this additional course is to ensure that under exam pressure you are easily capable of solving any question asked but that on successfully reaching A2 you are capable of undertaking an extended programming project. For this reason some tasks will appear larger than necessary at AS - this is not the case - we are purely preparing you for the tasks ahead.The tasks are built around Java but should be possible other languages such as Javascript or Python but I will not support anything VB/Microsoft related. We prefer Java-esque languages/APIs such as Android(KS5) & Greenfoot(KS3). We use the Free Open Source IDEs: NetBeans and Eclipse (for Android).Don't get fixated by the extensions, some of them are hard - you can always return later having completed other tasks to improve it using your new found knowledge.If you get stuck by all means use the internet to find answers but try to look for help understanding the technique rather than looking for a particular answer. So for the Area Calculator you might google multiplying numbers in Java and not calculate area of rectangle in Java.Good Luck and enjoy - programming should be fun.Hello World
Write a program which returns the phrase “Hello World!” to the screen.
Extension: You can extend this program by getting the program to take a name as a string argument. The program should then return “Hello Name!” to the screen.LO: Sequence; Basic String I/OUpper or Lower
Write a program that given a mixed case sentence outputs upper and lower case versions. The program should be dynamic so that the user can enter a string.
Example Output:You entered: Once Upon A Timelowercase: once upon a timeUPPERCASE: ONCE UPON A TIMELO: String Operations.Area Calculator
Create a program(s) that will calculate the area of:
- A Rectangle
- A Triangle
- A Circle
- A Polygon
Extension: You might look at using: IFs to decide on the shape; Methods to split up the code; and Maths Libraries for PI but simple programs can be created without any of these.LO: Variables, Arithmetic Operations, Basic I/OUnit Convertor
Write a simple GUI that converts any given number into another computer unit unit. Computer units: byte, kilobyte, megabyte etc...
LO: Doubles; Methods; Java GUIs.String Replace
Write a program that replaces all the vowels in a word with a dash (-). You should use a String.replace() method.
Note: you will need to call replace more than once to remove all vowels unless you complete the extension.Extension: Advance your program so it uses regular expressions to replace any character(s) in your string with a dash (-).LO: String Operations.Middle Char
One of my favourites. Write a program that tests the length of a string. If the String is even it will output 'even'. If the string is odd it will output 'odd'.
You will need to use an IF statement and find the length of the string using the String.length() method.Note: The modulus of the string's length e.g. length % 2 will return either 0 or 1 which you can use to determine odd or evenLO: String Operations; IF Selection; Modulus.Splitting Sentences
Write a program that splits a sentence into words and outputs each word on a separate line.
To complete this task you will need to look at the String.split() method and be able to use a 'for' to loop through the array results.LO: String Operations; For Loops; Arrays.The Plural-izor!
Write a program that takes a word and returns its plural version. This is a good opportunity to use certain tools so make sure you check out the LOs below. If you are not sure on the plural rules then check out http://bit.ly/VJ416z
LO: Select Case Selection; SubString; Concatenation.Valid Byte
Write a function called IsValidByte which takes a string as its argument and returns TRUE if the string has exactly 8 characters which are all “0” or “1”. For example: IsValidByte(“01101010”) should return TRUE IsValidByte(“1101010”) and IsValidByte(“01201101”) should both return FALSE.
LO: String OperationsAdd Bytes
Write a function called AddBytes which takes two valid strings representing bytes as its arguments and returns a string which represents the sum of the two bytes using Binary arithmetic. For example AddBytes(“10010100”, “01001101”) should return “11100001”
Note that you are NOT ALLOWED to convert these strings to their equivalent integers!Extension: How does your function cope with overflow?).LO: String Operations; While Loops.Count Letters
Write a function called CountOccurences which takes two arguments. The first is a single-character string and the second is a string of any length. The function should return the number of times that the character occurs in the second argument. For example: CountOccurences(“a”,“Bananarama”) should return the integer 5.
Extension: For a challenge: add a third argument of type Boolean. If this argument is TRUE then the search is case-sensitive, if it is FALSE then the search ignores case. It should default to FALSE. If the language used by the centre allows it, this third argument could be optional – defaulting to TRUE.LO: Methods, String Operations.Wake Up, it's time to die.
Write a program that takes two dates (one could be today/now) and the other one which is sometime in the future and calculates the time to go. Basically create a countdown timer and/or birthday calculator.
Extensions:- Determine the day that a given date occurs on.
- Make it work for dates in the past.
LO: Dates.Reversing Strings
Read in a file containing a nursery rhyme before reversing all the lines and writing out the result.
Extensions:- Reverse the order of words in each line before writing back to the file.
- Sort out the sentence case for each new reversed line.
LO: String Operations, File I/OCracking Codes
Produce a program which will read unencrypted ‘plaintext’ text from a file and encode it with a shift of 2 before writing the encoded ‘ciphertext’ to a new file.
Extensions:- Allow any shift value to be given.
- Write a Function called Atbash which encodes the file using AtBash e.g. A ↔Z, B ↔Y, C ↔X etc.
LO: File I/O; String Operations.Problem 17 from Project Euler.
Write a program which works out how many letters are used if a number is written as words. For Example:
- 1 becomes One and uses 3 letters,
- 7 becomes Seven and uses 4 letters (S,E,V,N),
- 256 becomes two hundred and fifty-six and uses 15 letters.
Note: this is a really good opportunity to employ recursive techniques.LO: Recursion.Topic 16
Word CounterYou have been provided with the Christmas Carol by Charles Dickens in text file format. There are a number of tasks that you are to perform with this file:- Read the contents of the file into a data structure counting the number of times each word occurs.
- Write the results back out to another results file using CSV format.
- It should also be possible to search for a word returning the number of times it occurs.
- Calculate the time taken to load the words and to find a search word.
You will need to explore different data structures. It is possible to complete this task with arrays but it will not provide the most efficient solution. As an extension you could explore linked lists and hash tables. The example program uses Java ArrayLists and HashMaps and shows how the latter provides a more rapid solution.Another version of this task is at http://w2.compu2learn.co.uk/word-counter/222LO: File I/O; Data Structures;Wari
Taken from Task 3 2008 AS OCR Computing (~22.5 Hours).
Wari is a game played on a board that consists of 12 cups placed in two parallel rows of six cups and a large cup at each end. The game is for two players; each player has a row of six cups and one large cup for prisoners.For more details go to http://compu2learn.co.uk/wari-gameRoman Numbers
Taken from Task 3 2006 AS OCR Computing (~22.5 Hours).
A manufacturing company wishes to make a new calculator that allows a user to input two numbers using Roman numerals and displays the numbers in both Roman and Arabic decimal forms. The calculator then allows a user to add or subtract the two numbers and again displays the result in both Roman and Arabic decimal forms.For the full information go to http://w2.compu2learn.co.uk/roman-numbers/213Snakes and Ladders
Taken from Task 3 2005 AS OCR Computing (~22.5 Hours)
A manufacturer of games has decided to design a new snakes and ladders board consisting of 100 squares. The manufacturer has asked a systems analyst to design a simulation of the game using different designs.For full information go to http://w2.compu2learn.co.uk/snakes-and-ladders/217Votes
Taken from Task 3 2007 AS OCR Computing (~30 hours).
One of the ways in which votes may be counted in an election is by a transferable vote system. There are a number of such systems in use in different parts of the world. One of them is called the Alternative Vote (AV) system. For this task the AV system is implemented in the way described below and this is the only method to be used in this task.For full details go to http://w2.compu2learn.co.uk/votes/218