Download presentation
Presentation is loading. Please wait.
Published byGinger Welch Modified over 8 years ago
2
Page 1 Lecture Exercise ( Wk3) CS1301 Introduction To Computer Programming (07-08 Semester B) www.cs.cityu.edu.hk/~helena Question 1. There are 3 errors in the given code (one is not visible). Can you find some of them? Question 2. Fill in the missing code: -- In the application, the user can type a name and then click "Invitation", then the corresponding message is updated, with "Dear …" displayed in the span: " Demo <body onload="alert('CS1301 Introduction to Computer Programming');"> CS1301 <a href="javascript: document.getElementById('info') ='CS1301 ' + 'Introduction to Computer Programming ' + ' - Computer programming is the craft of ' + 'writing useful, maintainable, and extensible instructions ' + 'which can be interpreted by a computing system ' + 'to perform a meaningful task. ' ; void(0);"> Display the details LectEx03Q1.html Demo <input type="button" value="Invitation" /> Please come to my birthday party on May 18, 2007. See you! Yours, Helena LectEx03Q2.html
3
Page 2 Lecture Exercise CS1301 Introduction To Computer Programming (07-08 Semester B) www.cs.cityu.edu.hk/~helena if pink say “put it on” else say “pass to sister” if yellow say “put it on” else say “pass to sister” if blue say “put it on” else say “pass to sister” Mother will give Mary a hat. The hat has one single color. But Mary likes pink, yellow, and blue only. For any other color she will pass it to her sister. Mary writes the “code” below. However, the code is often confusing : - Sometimes it says “put it on” but then it will say “pass to sister”. - Sometimes it says “pass to sister” but then it will say “put it on”. Use flowchart to analyze it. Design the correct one. (She should say one single decision only.) When Mary chooses a boy friend, she wants him to be kind, polite and hardworking. She rejects those who are not kind, or not polite, or not hardworking. Which one(s) of the below is/are correct (or confusing)? if kind and polite and hardworking say “let's be friends” else say “please go away” Correct Wrong Confusing if kind or polite or hardworking say “let's be friends” else say “please go away” Correct Wrong Confusing if kind say “Let's be friends!” else if polite say “Let's be friends!” else if hardworking say “Let's be friends!” else say “Great! Let's be friends!” Correct Wrong Confusing if kind if polite if hardworking say “Great! Let's be friends!” say “please go away” Correct Wrong Confusing if not kind say “please go away” else if not polite say “please go away” else if not hardworking say “please go away” else say “Great! Let's be friends!” Correct Wrong Confusing
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.