Question 6
AQA Computer Science Specimen Paper 1 (7517/1)A level14 marks
On the specification
- 6.1
- 3.1 Fundamentals of programming3.5 Fundamentals of data representation
- 6.2
- 3.3 Systematic approach to problem solving
Question text
6 Create a folder/directory called Question6 for your new program. One method for converting a decimal number into binary is to repeatedly divide by 2 using integer division. After each division is completed, the remainder is output and the integer result of the division is used as the input to the next iteration of the division process. The process repeats until the result of the division is 0. Outputting the remainders in the sequence that they are calculated produces the binary digits of the equivalent binary number, but in reverse order. For example, the decimal number 210 could be converted into binary as shown in Figure 7. Figure 7 210 ÷ 2 = 105 remainder 0 105 ÷ 2 = 52 remainder 1 52 ÷ 2 = 26 remainder 0 26 ÷ 2 = 13 remainder 0 13 ÷ 2 = 6 remainder 1 6 ÷ 2 = 3 remainder 0 3 ÷ 2 = 1 remainder 1 1 ÷ 2 = 0 remainder 1 The sequence 0, 1, 0, 0, 1, 0, 1, 1 which would be output by this process is the reverse of the binary equivalent of 210 which is 11010010. What you need to do Task 1 Write a program that will perform the conversion process described above. The program should display a suitable prompt asking the user to input a decimal number to convert and then output the bits of the binary equivalent of the decimal number in reverse order. Task 2 Improve the program so that the bits are output in the correct order, e.g. for 210 the output would be 11010010. Task 3 Test the program works by entering the value 210. Save the program in your new Question6 folder/directory. Evidence that you need to provide Include the following in your Electronic answer document. 6.1 Your PROGRAM SOURCE CODE after you have completed both Task 1 and Task 2. If you complete Task 1 but do not attempt Task 2 then a maximum of 9 marks will be awarded. [12 marks] 6.2 SCREEN CAPTURE(S) for the test showing the output of the program when 210 is entered. The marks for this test will be awarded whether the binary digits are output in reverse order or in the correct order. [2 marks] END OF SECTION B You are advised to spend no more than 15 minutes on this section. Type your answers to Section C in your Electronic Answer Document. You must save this document at regular intervals. These questions refer to the Preliminary Material and require you to load the Skeleton Program, but do not require any additional programming. Refer either to the Preliminary Material issued with this question paper or your electronic copy.