Question 10

AQA Computer Science June 2017 Paper 1AS11 marks

On the specification

10.1
3.1 Fundamentals of programming3.2 Fundamentals of data structures
10.2
3.3 Systematic approach to problem solving
10.3
3.3 Systematic approach to problem solving
Question text

10 This question will extend the simulation program to allow Field data to be saved to a text file. When the simulation has run for the required number of years, the user should be given the option of saving the Field data to a text file. This text file must represent the data in the same format as the file TestCase.txt stores it (see Figure 7), including the numbers at the end of each line. Figure 7 S | 0 X | 1 | 2 SSSSSSXSSSSSSSSSS...S | 3 | 4 S.S S.S | 5 S S | 6 S.SSSSSSSSSSXSS.S | 7 S.S S.S | 8 ..X | 9 S.S.S S.S.S | 10 S.X.S.SSSSS.S.S.S | 11 S.S.S.S...S.S.S.S...X | 12 S.S.S.S.S.S.S.S.S | 13 S.S.S.S...S.S.S.S | 14 S SSSSS S | 15 S.S.S S.S.S | 16 XX S | 17 S.S S.S | 18 S S | 19 What you need to do: Task 1 Create a new subroutine SaveToFile. This subroutine is to ask the user whether they want to save the data by displaying the message: Save the current Field state to a text file? (Y/N): If the user chooses to save the data, the subroutine is to create a new text file with a user-specified filename and store the formatted data in it. Task 2 In the subroutine Simulation add a call to the subroutine SaveToFile in an appropriate place. Task 3 Test that the subroutine SaveToFile works by conducting the following test: • run the simulation for two years • do not load a data file • save the data to file Test1.txt Task 4 • run the simulation for one year • load the data file Test1.txt Evidence that you need to provide Include the following in your Electronic Answer Document. 10.1 Your PROGRAM SOURCE CODE for the subroutines SaveToFile and Simulation. [9 marks] 10.2 For the first run of the simulation: SCREEN CAPTURE(S) showing the Field displayed for winter year 2 including the user interaction for saving the data. [1 mark] 10.3 For the second run of the simulation: SCREEN CAPTURE(S) showing the Field displayed for spring year 1 including the user interaction for loading the data file. [1 mark]