Cambridge IGCSE & O Level Computer Science Programming Book for Microsoft Visual Basic Sample

Page 48

We are working with Cambridge Assessment International Education towards endorsement of this title. Any references or material related to answers, grades, papers or examinations are based on the opinion of the author(s). CAMBRIDGE IGCSE™ & O LEVEL COMPUTER SCIENCE: PROGRAMMING BOOK

CHALLENGE TASKS 2.1–2.2 2.1 A system is required by a teacher to calculate grades in an examination. The teacher will input the maximum marks that could have been achieve in the examination and the actual mark achieved by the student. The system will output the grade based on these boundaries: Grade as Distinction if percentage above 80

Grade as Merit if percentage in range 61–80

Grade as Pass if percentage in range 40–60

Grade as Fail if percentage less than 40.

LE

Design a flowchart to show the logic of the system required to output the correct grade.

2.2 A program is needed to work as a calculator. The user is asked to input two separate numbers and an arithmetic operation (+ , ×, ÷ or −). The program must then calculate the answer. This answer must be output. Design a flowchart to show the logic of the system required to complete this task.

SUMMARY

P

M

Programmers make use of three constructs when writing code: •

sequence: the logical order in which the code is executed

selection: branching of code onto different paths based on certain conditions

iteration: repeating of sections of code.

Before coding a program it is crucial to design an appropriate algorithm using either a flowchart or pseudocode.

A

Flowcharts use a series of symbols to visually represent the logic of a program. The flow of the execution of the program is represented by flow lines with arrow heads to show the direction of flow. It is crucial that the correct symbols are used. The examination board will provide a flowchart guide and you must become familiar with the expected symbols. Flowchart design can be done in two stages: the first stage is to consider the logic steps and processes required for the algorithm

the next step is to consider how those steps could be achieved and ensure the flowchart contains enough detail to fully describe each step.

S

Decision symbols in flowcharts need to include precisely defined mathematical conditions. These should be defined using appropriate mathematical symbols such as > or <, for example, use A < B rather than A is less than B. Pseudocode is a method of describing the logic of a program by using written language. The language used includes a series of key words that describe the exact programming constructs used in the program. It is important that you comment your pseudocode (using the // symbol) to help explain the logic of your algorithm.

36 Original material © Cambridge University Press 2021. This material is not final and is subject to further changes prior to publication.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Cambridge IGCSE & O Level Computer Science Programming Book for Microsoft Visual Basic Sample by Cambridge International Education - Issuu