Difference between revisions of "2016 Old Spec"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(What you need to do)
(Figure 4)
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
  
The algorithm, represented using pseudo-code in Figure 4, and the variable table, Table 2, describe a program that outputs an estimate for a particular calculation.
+
The algorithm, represented using pseudo-code in '''Figure 4''', and the variable table, '''Table 2''', describe a program that outputs an estimate for a particular calculation.
  
 
=Figure 4=
 
=Figure 4=
Line 10: Line 10:
 
  F = 16.0
 
  F = 16.0
 
  IF N >= 1.0
 
  IF N >= 1.0
:THEN
+
  THEN
::X = N
+
    X = N
::WHILE X * X – N > 1.0 AND F – 1.0 > 1.0 DO
+
    WHILE X * X – N > 1.0 AND F – 1.0 > 1.0 DO
:::L = X
+
      L = X
:::X = X ÷ F
+
      X = X ÷ F
:::WHILE X * X <= N DO
+
      WHILE X * X <= N DO
::::F = F – 0.1
+
        F = F – 0.1
::::X = L ÷ F
+
        X = L ÷ F
:::ENDWHILE
+
      ENDWHILE
::ENDWHILE
+
    ENDWHILE
::OUTPUT X
+
    OUTPUT X
:ELSE
+
  ELSE
::OUTPUT "Not a number greater than or equal to 1"
+
    OUTPUT "Not a number greater than or equal to 1"
 
  ENDIF
 
  ENDIF
 +
 +
=Table 2=
 +
{|
 +
|-
 +
! Indentifier
 +
! Data Type
 +
|-
 +
| X
 +
| Real Number
 +
|-
 +
| F
 +
| Real Number
 +
|-
 +
| L
 +
| Real Number
 +
|-
 +
| N
 +
| Real Number
 +
|}
  
 
=What you need to do=
 
=What you need to do=

Latest revision as of 13:20, 29 November 2016

Question 5

The algorithm, represented using pseudo-code in Figure 4, and the variable table, Table 2, describe a program that outputs an estimate for a particular calculation.

Figure 4

OUTPUT "Enter a number:"
INPUT N
F = 16.0
IF N >= 1.0
  THEN
    X = N
    WHILE X * X – N > 1.0 AND F – 1.0 > 1.0 DO
      L = X
      X = X ÷ F
      WHILE X * X <= N DO
        F = F – 0.1
        X = L ÷ F
      ENDWHILE
    ENDWHILE
    OUTPUT X
  ELSE
    OUTPUT "Not a number greater than or equal to 1"
ENDIF

Table 2

Indentifier Data Type
X Real Number
F Real Number
L Real Number
N Real Number

What you need to do

  • Write a program for the algorithm in Figure 4.
  • Test the program by conducting the tests:
  1. Test that your program works correctly by entering the number 0.1
  2. Test that your program works correctly by entering the number 4.1