CS1101: Programming Methodology Aaron Tan.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

CS1010 Programming Methodology
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
Introduction to Computer Programming in C
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
CS211 Data Structures Sami Rollins Fall 2004.
CS 101 Problem Solving and Structured Programming in C Sami Rollins Spring 2003.
Recitation 1 Programming for Engineers in Python.
CS1101: Programming Methodology Aaron Tan.
CS1101: Programming Methodology
CS1101: Programming Methodology Aaron Tan.
Variables in Java Part 2. ICS-3M1 - Mr. Martens - Variables Part 2 Recall the “int” Data Types When you divide one integer by another – you always get.
CS1101: Programming Methodology Aaron Tan.
CPS 2231 Computer Organization and Programming Instructor: Tian (Tina) Tian.
19/5/2015CS150 Introduction to Computer Science 1 Announcements  1st Assignment due next Monday, Sep 15, 2003  1st Exam next Friday, Sep 19, 2003  1st.
CS1101: Programming Methodology Aaron Tan.
CS1101: Programming Methodology
Strange ! Here is a small mathematical exercise, that will certainly Give everyone a surprise! Press [enter] to see next slide.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
CS1010: Programming Methodology
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
Lecture 11.   Modular arithmetic is arithmetic in which numbers do not continue forever.  Modulo 7 has numbers 0, 1, 2, 3, 4, 5, and 6.  Modulo 5.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Agenda Review C++ Library Functions Review User Input Making your own functions Exam #1 Next Week Reading: Chapter 3.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CS1101: Programming Methodology
CS1101: Programming Methodology Aaron Tan.
Procedural Programming. Programming Process 1.Understand the problem 2.Outline a general solution 3.Decompose the general solution into manageable component.
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
CS1101: Programming Methodology Aaron Tan.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
CS1101: Programming Methodology Aaron Tan.
Intro to CS ACO 101 Lab Rat. Academic Integrity What does that mean in programming? Log into Blackboard and take the test titled “Applied Computing Course.
CS 100Lecture 21 CS100J: Lecture 2 n Previous Lecture –Programming Concepts n problem, algorithm, program, computer, input, output, sequential execution,
© 2006 Pearson Education 1 Obj: to use assignment operators HW: Prelab Exercises 2 Quiz 3.1 – 3.4 in two class days  Do Now: 1.Read p.144 – 145 (3.4 “more.
Programming Fundamentals I Java Programming Spring 2009 Instructor: Xuan Tung Hoang TA: Tran Minh Trung Lab 03.
The Hashemite University Computer Engineering Department
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Lecture 7: Menus and getting input. switch Multiple-selection Statement switch Useful when a variable or expression is tested for all the values it can.
1 CS161 Introduction to Computer Science Topic #6.
CS1101: Programming Methodology
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
MGS 351 Introduction to Management Information Systems RECITATION 9.
CS 100Lecture 11 Introduction to Programming n What is an algorithm? n Input and output n Sequential execution n Conditional execution Reading: Chapter.
CS1010: Programming Methodology
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Quiz 1 Exam 1 Next Monday. Nested if Statements if (myGrade >= 80) if (myGrade >= 90) System.out.println(“You have an A!” ); else System.out.println(“You.
CS1101: Programming Methodology Aaron Tan.
CS2100 Computer Organisation
Introduction to Computer Programming
CS1010 Programming Methodology
Completing the Problem-Solving Process
EGR 2261 Unit 4 Control Structures I: Selection
Think What will be the output?
Chapter 3 Control Statements Lecturer: Mrs Rohani Hassan
CIS 407 STUDY Education for Service-- cis407study.com.
Introduction to Programming
CS1100 Computational Engineering
Learning Outcomes –Lesson 4
Problem Solving Skill Area 305.1
SELECTIONS STATEMENTS
SE1H421 Procedural Programming LECTURE 4 Operators & Conditionals (1)
Building Java Programs
Module 3 Selection Structures 6/25/2019 CSE 1321 Module 3.
Presentation transcript:

CS1101: Programming Methodology Aaron Tan

2 This is Week 3  Last week:  Java Basics  Variables, assignment statements, arithmetic operators, input and output, etc.  Object-oriented programming? Not yet!  This week:  Selection constructs  First part of Chapter 4 Control Statements  ‘if’, ‘switch’, logical operators

3 It Pays to Explore!  IVLE forum  I don’t like such questions   Can you tell me the output of this program?  What is wrong with my program?  My friend told me this is the way to do it. Is he correct?  I love such questions  I’ve tried this program. The result is different from my expectation, which is … I was surprised! But why it doesn’t give me my expected result?  I surfed the Internet and found this. I tried but I don’t understand. Can you explain it?

4 Quiz Time…  10 MCQs

5 Exercise #1  Given this code to find the maximum among 3 integer values in variables num1, num2 and num3:  // To find the maximum among 3 integer // values in variables num1, num2, num3. int max = 0; if (num1 > num2 && num1 > num3) max = num1; if (num2 > num1 && num2 > num3) max = num2; if (num3 > num1 && num3 > num2) max = num3;  Spot the errors

6 Exercise #1  Another version:  // To find the maximum among 3 integer // values in variables num1, num2, num3. int max = 0; if (num1 > max) max = num1; else if (num2 > max) max = num2; else if (num3 > max) max = num3;  Spot the errors

7 Exercise #2  Download the file IfAndSwitch.java from the Lectures page in the course website:  sources/lectures.html sources/lectures.html  Correct the errors in the code  Change the ‘if’ statements into a ‘switch’ statement.

8 Exercise #3 (Prep for Exercise #4)  Given a 7-digit integer, extract the individual digits from the integer.  Sample run is shown below Enter a 7-digit number: Digits are: 8,5,0,4,2,1,5  You should use int variables for the 7 digits (digit1, digit2, …)  Do not use ‘if’ statement.

9 Exercise #4  Algorithm for NRIC check code  NRIC consists of 7 digits.  Eg:  Step 1: Multiply the digits with corresponding weights 2,7,6,5,4,3,2 and add them up.  Eg: 8        2 = = 104  Step 2: Divide step 1 result by 11 to obtain the remainder.  Eg: 104 % 11 = 5

10 Exercise #4  Algorithm for NRIC check code (cont…)  Step 3: Subtract step 2 result from 11  Eg: 11 – 5 = 6  Step 4: Match step 3 result in this table for the check code  Eg: The check code corresponding to 6 is ‘F’.  Therefore, the check code for is ‘F’ ABCDEFGHIZJ

This is Week 3  Next week?  Repetition statements  ‘while’, ‘do while’, ‘for’

12 Reminder  Trial Lab  Deadline: 27 August (Wednesday), 2359hr.

13 End of file