12Programming Structure VIII

# 12Programming Structure VIII - Find Highest Mark...

This preview shows pages 1–3. Sign up to view the full content.

Self-revision Exercise t is wrong to design the code as follow: function findHighestMark() { var hm; hm=parseInt(document.F1.CMark.value); if (parseInt(document.F1.EMark.value)>hm) hm=parseInt(document.F1.EMark.value); else if (parseInt(document.F1.MMark.value)>hm) hm=parseInt(document.F1.MMark.value); alert(hm); } Your task: (1) Draw flowcharts for the original version and this wrong version. (2) Explain why this version is wrong. Try the following input: Chinese: 65 English: 85 Mathematics: 95 You can observe a wrong output Find Highest Mark

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Introduction to Variables Set hm ’s value using " = " (assignment operator) : Example 1: hm=80; store the number 80 at the memory location referred by hm . Example 2: hm=document.F1.Cmark.value; Suppose Chinese mark is 90, then 90 is stored at the memory location referred by hm . Use the value of hm : For short, we say " hm is equal to [ the value at the memory location referred by hm ] ". Example: Suppose 90 is the value stored there, then we say " hm is equal computer's memory: 80 90 hm ariable declaration using the
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

12Programming Structure VIII - Find Highest Mark...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online