46.6k views
1 vote
William is creating a film for a school project using a digital video camera.

William transfers the videos to a computer for editing.

(i) The computer has 1GB of storage free.

Calculate the number of videos that could be stored on the computer if each video was 100MB in size.

Show your working.

(ii) A program needs to calculate the size of files in bytes. The program must:

· Ask the user to input a file size in megabytes
· calculate and output the number of bytes this represents in a user friendly format.
(e.g. "There are 5242880 bytes in 5MB").

Write an algorithm using pseudocode to calculate the number of bytes in a given number of megabytes.

User Kamani
by
8.1k points

2 Answers

2 votes

Answer:

(i) Calculation:

1 GB = 1000 MB

Number of videos that could be stored = (1 GB / 100 MB) = 10

Therefore, William can store 10 videos on his computer if each video is 100MB in size.

(ii) Algorithm using pseudocode:

Ask the user to input the file size in megabytes.

Multiply the file size by 1,000,000 to convert it to bytes.

Print the result in a user-friendly format by dividing the bytes by 1,048,576 and rounding to two decimal places, and adding "MB" and "bytes" to the output.

Pseudocode:

Input file_size_in_mb

Set bytes = file_size_in_mb * 1000000

Set result = round((bytes / 1048576), 2)

Output "There are " + result + " MB " + bytes + " bytes".

User Jens Schwarzer
by
8.3k points
2 votes
(i) To calculate the number of videos that could be stored on the computer:

1GB = 1000MB (since 1GB = 1024MB, but we'll use the simpler 1000MB approximation here)

Number of videos = (1GB free space) / (100MB per video)
Number of videos = (1000MB) / (100MB per video)
Number of videos = 10 videos

Therefore, if each video is 100MB in size, William can store a maximum of 10 videos on the computer.

(ii) Algorithm to calculate the number of bytes in a given number of megabytes:

1. Ask the user to input the file size in megabytes.
2. Read the input and store it in a variable, let's call it "megabytes".
3. Calculate the number of bytes by multiplying "megabytes" by 1,048,576 (this is the number of bytes in a megabyte).
4. Output the result in a user-friendly format, such as: "There are [number of bytes] bytes in [megabytes] MB."

Here's the pseudocode:

```
INPUT megabytes
bytes = megabytes * 1048576
OUTPUT "There are " + bytes + " bytes in " + megabytes + " MB."
```
User Shl
by
8.1k points