Photo AI

A program is being created to convert the data capacity of a storage device into a different measure - OCR - GCSE Computer Science - Question 5 - 2021 - Paper 1

Question icon

Question 5

A-program-is-being-created-to-convert-the-data-capacity-of-a-storage-device-into-a-different-measure-OCR-GCSE Computer Science-Question 5-2021-Paper 1.png

A program is being created to convert the data capacity of a storage device into a different measure. The function, calculate(), takes the measurement (e.g. gigabyt... show full transcript

Worked Solution & Example Answer:A program is being created to convert the data capacity of a storage device into a different measure - OCR - GCSE Computer Science - Question 5 - 2021 - Paper 1

Step 1

if measurement == "gigabytes" then

96%

114 rated

Answer

value = number * 1024 * 1024 * 1024 * 8

Step 2

elseif measurement == "megabytes" then

99%

104 rated

Answer

value = number * 1024 * 1024 * 8

Step 3

elseif measurement == "kilobytes" then

96%

101 rated

Answer

value = number * 1024 * 8

Step 4

elseif measure == "bytes" then

98%

120 rated

Answer

value = number * 8

Step 5

else

97%

117 rated

Answer

return -1

Step 6

return ______________________

97%

121 rated

Answer

return value

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;