Skip to content
Gallery
Software Design and Development
Share
Explore
Week 7

Evidence of Learning

027. T1W7 Evidence - Well Written Code, Error Types, and Error Detection

Q1. Write an algorithm for the following problem: A user enters a mark out of 50. The program then scales this mark to a mark out of 100. Once it is out of 100, it then checks this mark and gives a grade based on:
<50: “Fail”,
>=50: “C”,
>=70: “B”,
>=90: ”A”
Demonstrate as many of the standards for well-written code that apply to this task.
BEGIN StudentMarking
INPUT Mark // Receives user input
IF Mark >= 50 || =< 0 // Check if mark is above or below 50 or 0.
PRINT "Mark is not valid. (Over 50 or below 0)"
END StudentMarking // End program and print error if mark is invalid.
END IF
ScaledMark = Mark * 2 // Scale the mark to be out of 100
IF ScaledMark < 50 // Prints grade based on scaled mark
PRINT "Fail"
ELSE IF ScaledMark >= 50
PRINT "C"
ELSE IF ScaledMark >= 70
PRINT "B"
ELSE IF ScaledMark >= 90
PRINT "A"
END IF
END StudentMarking

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.