Page 1 Lecture Exercise (Wk4) CS1301 Introduction To Computer Programming (07-08 Semester B) www.cs.cityu.edu.hk/~helena Question 2 According to the following.

Slides:



Advertisements
Similar presentations
Chapter 2: Problem Solving
Advertisements

Chapter 1 - An Introduction to Computers and Problem Solving
Lecture Exercise (9) CS1301 Introduction To Computer Programming (07-08 Semester B) Random Student Numbers 1: 2: 3: 4: 5:
Lecture Supp (11) Week 10 lecture exercise [Given Code] LectEx10_ShowPrimeNumbers.html If we remove both “var” for i, then the new window shows ‘3’ repeatedly.
1 9/26/08CS150 Introduction to Computer Science 1 Logical Operators and if/else statement.
Title Explaining what is being done and what method How much was added and the conc. Instrument Settings Modifications to written experiment noted as proceded.
1 CS1301 Introduction To Computer Programming (07-08 Semester B) Lecture Exercise (Wk8) Q.1 [Use of while-loop] (a) Write.
Page 1 Lecture Exercise ( Wk2) CS1301 Introduction To Computer Programming (07-08 Semester B) Question 1. MATCHING: html comments.
CS 106 Introduction to Computer Science I 03 / 23 / 2007 Instructor: Michael Eckmann.
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
Computer Science 1620 Programming & Problem Solving.
Any questions on the Section 2.1 homework that was due today?
Midterm Logistics Where? 2050 VLSB When? Monday, 4:10 to 5:40 What to do? –“Review problems” from Thursday/Friday in UCWise. –Two practice exams and solutions.
Modules, Hierarchy Charts, and Documentation
The If/Else Statement, Boolean Flags, and Menus Page 180
1 9/28/07CS150 Introduction to Computer Science 1 Logical Operators and if/else statement.
CS 106 Introduction to Computer Science I 09 / 28 / 2007 Instructor: Michael Eckmann.
Guide to MCSE , Enhanced 1 Activity 4-1: Creating and Adding Members to Global Groups Objective: Use Active Directory Users and Computers to create.
Bret Juliano. Introduction What Documentation is Required? – To use a program – To believe a program – To modify a program The Flow-Chart Curse Self-Documenting.
Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa USE CASES In this lecture: Use cases - What are use.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
5.4 Applications of Percent
Documentation and Comments. What’s a comment? A comment is a simple form of documentation. Documentation is text that you the programmer write to explain.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
How to start Visual Studio 2008 or 2010 (command-line program)
CSE 201 – Elementary Computer Programming 1 Extra Exercises Source: Suggested but not selected midterm questions.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
Page 1 Lecture Exercise ( Wk3) CS1301 Introduction To Computer Programming (07-08 Semester B) Question 1. There are 3 errors.
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
CS Class 08 Today  Exercises  Nested loops  for statement  Built-in functions Announcements  Homework #3, group solution to in-class.
Lecture 5: Stopping with a Sentinel. Using a Sentinel Problem Develop a class-averaging program that will process an arbitrary number of grades each time.
Using Lists Games Programming in Scratch. Games Programming in Scratch Extension – Using Lists Learning Objectives Create a temporary data store (list)
1 10/3/05CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Programming Fundamentals Introduction to Problem Solving  Programming is a problem solving activity. When you write a program, you are actually writing.
Formal Lab Reports Prince Andrew High School. Title Page At the bottom right corner of the title page, include: Title Presented to Teacher’s name By Student’s.
Lecture Exercise (Wk4) CS1301 Introduction To Computer Programming (11-12 Semester B) Page 1 Question 2 (a)Complete the code.
Lab 9 Exercises.
CPSC 233 Tutorial 5 February 2 th /3 th, Java Loop Statements A portion of a program that repeats a statement or a group of statements is called.
CS1301 Introduction To Computer Programming (11-12 Semester B) Lecture Exercise (Wk8) Q.1 Write the code that asks the user.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Spring 16 CSCI 4430, A Milanova/BG Ryder 1 Announcements HW5 due March 28 Homework Server link is up I will have office hours, Fri or Mon, check Announcements.
Random Student Numbers 1: 2: 3: 4: 5: Generate random student numbers: Random Student Numbers 1: : : :
 Problem Analysis  Coding  Debugging  Testing.
CSC 1010 Programming for All Lecture 5 Functions Some material based on material from Marty Stepp, Instructor, University of Washington.
Page 1 Lecture Exercise ( Wk3) CS1301 Introduction To Computer Programming (11-12 Semester B) Question 1. Fill in the missing.
Introduction to Computer Programming
ALGORITHMS AND FLOWCHARTS
CS1022 Computer Programming & Principles
Lecture 3: Operators, Expressions and Type Conversion
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Introduction to Programming
Lecture 2 Introduction to Programming
Introduction to Computer Programming
Computer Science and an introduction to Pascal
Introduction to Programming
New Senior Secondary Mathematics Curriculum Sharing of SBA Task Exemplars (Draft) HKEAA September 2006.
Introduction to Programming
Learning Objective This lecture will cover following areas:
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Announcements Quiz 5 HW6 due October 23
Introduction to Programming
Creating Maintainable code
Hint idea 2 Split into shorter tasks like this.
Completing the Square pages 544–546 Exercises , – , –2
Creating readable code
Presentation transcript:

Page 1 Lecture Exercise (Wk4) CS1301 Introduction To Computer Programming (07-08 Semester B) Question 2 According to the following code, what will be shown in the page? Try calling functions function x1() {return 3+x2(8); } function x2(value) {return value*5; } document.write(x1()); calculate 3 + x2(8) and then return the result (i)var x, a, b; a = 4; b = 4*8; x = a+b; a = b; b = a; (ii)var a,b,x; a=1; b=2; x=3; 4=a; a+b=x; Question 1 Explain what are done (or error) by the code: Question 3 (a)Complete the following code to check whether a value x is odd or not. (Hint: use %) var x=prompt("Input a value for x"); if (________________) alert("It is even.",""); else alert("It is odd.");

Page 2 (b)We want to increase the salaries of both junior and senior staff by 10percents, but rounded up by 10 dollars. For example, Original salary is: 7730 After raising by 10percents => 8503 Then round up by 10 dollars => 8510 Design a function that can be called to do the calculation. (A solution: If raised - salary % 10 is equal to 0, no need to adjust. Otherwise calculate the amount to add.) Question 4 We usually add comments to explain our code. Particularly, we add comments (1) for all global variables (2) to describe functions (add simple comments before each function) (3) to briefly explain different parts of the code (4) for some complicated logic whose meaning / purpose is not obvious In formal practices, we also add comments at the beginning of the code to show (1) brief description of the application (2) name of the person who created / modified the code (3) creation / modification dates (4) any special notes for the user Add appropriate comments to the code: CS1301 DEMO var c=0; function count( ) {c=c+1; document.getElementById("counter").innerHTML=c; } Add 1 to the counter :