Example Selection Design

Problem: ExamSystem

Specification
Develop an algorithm for a program that will accept as input a students mark for an exam along with the total possible mark. The program should calculate the students mark as a percentage of the total possible mark and if the percentage mark is greater than or equal to 50 then the output should be a statement of ‘Pass’ or ‘Fail’.
Data Input(s) Data Processing Data Output(s)
ActualMark – Integer PercentageMark – Real Message displaying ‘Pass’ or ‘Fail’
PossibleMark – Integer
Data Processes (Using Sample Data)
Working out a sample answer allows you to understand the processing you want the computer to carry out. The data and answer worked out here can be used later to test the program.ActualMark = 50PossibleMark = 100PercentageMark = (ActualMark / PossibleMark) * 100PercentageMark = (50 / 100) * 100PercentageMark = (0.5) * 100

PercentageMark = 50

Algorithm
BeginGet ActualMarkGet PossibleMarkCalculate PercentageMark as (ActualMark / PossibleMark) * 100If PercentageMark is greater than or equal to 50Then

Display ‘Pass’

Else

Display ‘Fail’

EndIf

End

Data Table

 Identifier Description Type/Range
ActualMark Actual mark scored in the exam Integer
PossibleMark Total possible mark in the exam Integer
PercentageMark Students mark as a percentage of the total possible mark Real

Next: Example JavaScript Program