JAVA PROGRAMMING EXERCISES FOR KEY STAGE 3 AND 4

Department of Computer Science, The University of Liverpool, Liverpool, L69 3BX

Tel: 0151 725 4275, Email: general-enquiries@csc.liv.ac.uk, WWW: http://www.csc.liv.ac.uk



This www page presents a set of Java programming exercises, and sample solutions, for (England, Wales and Northern Ireland) key stages 3 and 4 pupils. Each problem comprises (for download): (i) a .pdf file presenting the problem, (ii) a suite of .java source codes files and (iii) in some cases additional supporting material. All material made available in this collection of www pages is made available free of charge for non-commercial usage. However, except where otherwise indicated, it remains the copyright of the University of Liverpool. Should you choose to make use of any of the material for teaching purposes we would greatly appreciate appropriate acknowledgement.

If you have a particular example problem that you would like to share we would be happy to include this (with appropriate acknowledgement of course).

The problems are categorised as follows:

  1. Sequence: Simple programming problems that use sequences of commands.
  2. Inheritance: Example problems that make use of the inheritance concept which is a feature of object oriented programmimg.
  3. Keyboard Input: Programmig example problem ussng keybopard input (something not quite as straight forward in Java as might be expected).
  4. Selection: Programme example problems that involve selection using "if-else" or "switch" ("case") statements.
  5. Repetition: Programme examples that involve repetition using "for" and "while" loop constructs.
  6. Arrays: Examp;e problems focused on the array daya structure.
  7. File Handling: Example problems that involve file input and outpit (also something that is not quite as straight forward in Java as might be expected).
  8. Landscape Gardening: Example problem exercises directed at a AQA GCSE specimen controlled assessment problem concerned with landscape gardening.

Under eaqch category problems are ordewred according to perceived difficulty.

#Problem Description/Notes .pdf .java
Sequence
1.1Giant LettersFirst Java Program, sequence of function calls utilising no input and only simple print string output statements. giantLetters2013-3-27.pdf. GiantJava.java and GiantJavaApp.java.
1.2Quote ItemSecond simple java problem that includes declaration of a number of fields (Based on an AQA GCSE specimen controlled assessment problem). quoteItem2013-4-28.pdf QuoteItem.java and QuoteItemApp.java
1.3Two Decimal Places UtilitySimple java problem that requires implementation of a static utility method. twoDecPlaceUtility2013-5-3.pdf Utility.java and UtilityApp.java
Inheritance
2.1Landscape Gardening Quote (with inheritance)Java problem that features inheritance. (Based on an AQA GCSE specimen controlled assessment problem). landscapeGardQuoteInheritance1_2013-5-12.pdf QuoteItem.java, QuoteItemType1.java, QuoteItemType2.java and QuoteItemApp.java
2.2Landscape Gardening Quote (with inheritance and totals)More sophisticate version of the "Landscape Gardening Quote (with inheritance)" problem but with arithmetic operators. We also make use of the Utility class created previously. (Based on an AQA GCSE specimen controlled assessment problem.) landscapeGardQuoteInheritance2_2013-5-7.pdf QuoteItem.java, QuoteItemType1.java, QuoteItemType2.java, Utility.java and QuoteItemApp.java
Keyboard Input
3.1Landscape Gardening Quote (Quote with Keyboard Input)The landscape gardening quote problem with keyboard input using the Scanner class (Based on an AQA GCSE specimen controlled assessment problem). landscapeGardKBinput_2013-5-7.pdf QuoteItem.java, QuoteItemType1.java, QuoteItemType2.java, Utility.java and QuoteItemApp.java
3.2Landscape Gardening Task 1(a): The Full QuoteSolution to landscape gardening AQA GCSE specimen controlled assessment problem Task 1(a) (with out the file output). landscapeGardeningTask1a_2013-5-12.pdf LandsGardQuote.java, Quote.java, QuoteItem.java, QuoteItemType1.java, QuoteItemType2.java, Utility.java and LandsGardQuoteApp.java
Selection
4.1Triangle RecognitionExample requiring signifcant use of "if-else" statements. triangles2013-3-30.pdf TriangleRecog.java and TriangleRecogApp.java
Repetition
5.1Menu InputExample using a while loop (and switch and if-else statements). menuApp2013-5-14.pdf MenuApp.java
Arrays
6.1Set IntersectionExample using arrays to represent sets and process them using a for loop (and switch and if-else statements). setIntersection2013-5-14.pdf SetOperations.java and SetIntersectionApp.java
File Handling
7.1File Output UtilityExample Java utility class (that can be imported into her Java classes) to support file output. fileOuput2013-5-14.pdf FileHandlingUtility.java and FileOutputApp.java
7.2File Input UtilityExtension of Java output utility class to include input and hence form a general file handling utility class.(that can be imported into her Java classes). fileInput2013-5-14.pdf FileHandlingUtility.java and FileInputApp.java
Landscape Gardening
8.1Landscape Gardening Task 1(b) (with file handling)Solution to landscape gardening AQA GCSE specimen controlled assessment problem Task 1 (generating and filing quotes). landscapeGardeningTask1b_2013-5-12.pdf FileHandlingUtility.java LandsGardQuote.java, Quote.java, QuoteItem.java, QuoteItemType1.java, QuoteItemType2.java, Utility.java and LandsGardQuoteApp.java.
8.2Landscape Gardening Task 2Solution to landscape gardening AQA GCSE specimen controlled assessment problem Task 2 (saving customer quotes). landscapeGardeningTask2_2013-5-12.pdf FileHandlingUtility.java LandsGardQuote.java, Quote.java, QuoteItem.java, QuoteItemType1.java, QuoteItemType2.java, Utility.java and LandsGardQuoteApp.java.
8.3Landscape Gardening Task 3Solution to landscape gardening AQA GCSE specimen controlled assessment problem Task 3 (loading new material costs). landscapeGardeningTask3_2013-5-12.pdf FileHandlingUtility.java LandsGardQuote.java, Quote.java, QuoteItem.java, QuoteItemType1.java, QuoteItemType2.java, Utility.java and LandsGardQuoteApp.java (and data Files).
8.4Landscape Gardening Task 4Solution to landscape gardening AQA GCSE specimen controlled assessment problem Task 4 (with quotes summary). landscapeGardeningTask4_2013-5-12.pdf FileHandlingUtility.java LandsGardQuote.java, Quote.java, QuoteItem.java, QuoteItemType1.java, QuoteItemType2.java, Utility.java, QuoteSummary.java, and LandsGardQuoteApp.java (Data Files: newMaterialCosts.txt, quoteNumber1.txt, quoteNumber2.txt, quoteNumber3.txt, quoteNumber4.txt, quoteNumber5.txt and quotesToDateFile.txt).



Created and maintained by: Frans Coenen. Created: Tuesday 9 April 2013. Last update: Sunday 28 April 2013.