12Programming Structure VIII

12Programming Structure VIII - Find Highest Mark...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online