coit29222 structured programming1 coit29222-structured programming lecture week01 reading: course...

23
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th Ed.), Chapters 1, 2 Study Guide Book 1, Modules 1,2,3,4 Introduction Computer Hardware Programming Languages Software Development Process Program Design-Pseudocode C++ History Simple C++ Program

Upload: lorena-mccormick

Post on 17-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 1

COIT29222-Structured Programming

Lecture Week01 Reading: Course Profile

Textbook (4th Ed.), Chapter 1 Textbook (6th Ed.), Chapters 1, 2

Study Guide Book 1, Modules 1,2,3,4IntroductionComputer HardwareProgramming LanguagesSoftware Development ProcessProgram Design-PseudocodeC++ HistorySimple C++ Program

Page 2: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 2

Introduction

Lecturer/Tutor Introduction-Write down name & contact details of your local lecturer and tutor

Timetable for Lectures, Tutorials & Workshops -Write down time & venue for lectures, tutorials & workshops

Course Profile-Read the course profile very carefully

Problems/Consultancy-If you have problems/doubts/do not understand something, talk to your local lecturer/tutor

Page 3: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 3

Textbook & Supporting Materials

Textbook-Deitel & Deitel, C++ How to program, 6th Edition, Prentice Hall

Supporting Materials-Staugaard A., Structured and Object Oriented Problem Solving Using C++, Prentice Hall -Study Guides Books 1, 2 and 3 -Visual C++ Compiler (Comes packaged with the textbook)

Web Page-http://webfuse.cqu.edu.au/Courses/2009/T3/COIT29222/ -check at least TWICE EACH WEEK

Subscribe To The Email List-subscribe COIT29222-t3

Page 4: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 4

Assessments

Assessment-Two Assignments– 20%, due Week 6; 30%, due Week 10– Online assignment submission

-Final Exam– Open book (restricted), 3-hour examination

To Be Eligible For A Passing Grade Or Better-You must score at least 50% of the overall marks available in the Assessment items AND must score at least 50% of the marks available in the Examination AND must score at least 50% overall

Page 5: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 5

Plagiarism & Assignment Extension

Plagiarism – Plagiarism of any kind is not permitted- Do not copy your assignment from a friend– Do not complete your assignments in groups

Assignment Extension

- You will need to fill in a form and submit it at your

campus administrative office

Page 6: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 6

TopicsTopics

- Brief Introduction to Computers and Programming Languages, Software Design, Coding Basics, Data Types, Selection Statements, Repetition Statements, Arrays & Strings, Functions, Files, Code Reuse, etc.

You will learn how to design, write and test C++ programs

You will not learn “object-oriented programming”

Page 7: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 7

Introduction to ComputersWhat is a Computer?

- A computer is a device which can process data and make logical decisions

Computer Hardware- Keyboard, “Mouse, Scanner, Microphone”

- Disks, Memory, CD-ROM

- Screen, Processor

Computer Software - Operating Systems (Windows, UNIX, LINUX)

- MS Word, Excel, PowerPoint, Acrobat Reader

- Compilers (Visual C++, Visual Basic, etc.)

- Finance Prediction, Medical Diagnosis, Games, etc.

Page 8: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 8

Introduction to Computers Computer Organization

Every computer can be divided into 6 units– Input unit– Output unit– Memory unit– Arithmetic and logic unit (ALU)– Central processing unit (CPU)– Secondary storage unit (bytes, Kbytes, Mbytes)

Computer Data (Binary, ASCII)Data is stored in binary form (1s and 0s) Example 1 = 00000001, 2 = 00000010a=01100001, A=01000001 (A is 65 in ASCII)Refer to Textbook, page 1216 (ASCII) and Appendix C, page 1218 (Number Systems)

Page 9: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 9

Software DevelopmentA 5-step Software Development Process

Task Analysis and SpecificationAnalyzing the problem & precisely specifying needs & constraints

Algorithm DesignDeveloping the logic using Pseudo-code/Flow charts

CodingConverting the algorithm into a computer program

TestingVerifying and validating code

MaintenanceMaintaining the software (fixing bugs, improvements,etc.)

Refer to Study Guide Book 1, Module 2

Page 10: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 10

Task AnalysisTask analysis may include:

Interviews with usersStudying documentation for an existing systemsStudying other documents that describe requirements

for the program

Two important skills are:Analysis – dissect task to expose sub-tasks Synthesis – combine different views into a “whole”

Analysts have tools for documenting their understanding of the requirements

Page 11: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 11

Modelling ToolsThe analyst uses graphical tools to

describe the system a program will support

A DFD shows the data flows in a system

StudentEnrolment

Process

Enrolment Form

Enrolment Advice

Enrolments StudentID,CourseCode

Student Details

Address

Page 12: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 12

Modelling ToolsAn ERD describes entities and

relationships that will be recoded in a database

Students

EnrolIn

Course Offered By

Faculties

M

M

StudentID

Name

Address

CourseCode

NameM 1

FacultyCode

Name

Dean

Page 13: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 13

Written SpecificationsAnalysts also produce a written specification of

the requirementsThe specification is verified by the client to

ensure that the right program is being builtThe Study Guide describes a 6-step process to

analyse a written specification:(1) read the description fully(2) rewrite the task in your own words(3) mark action, naming and information words and

phrases(4) make sure you understand the actions required(5) put the actions in the correct sequence(6) check your work

Page 14: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 14

Program DesignWith a clear understanding of the task(s) to be

performed, we start to design the programThe design of a program is often written in

pseudocodepseudocode is similar to everyday English

- Easy to understand

- Useful for developing algorithms

- Is not a computer programming language

- Does not compile or execute

We will use pseudocode in this course The pseudocode used in the Study Guide is as simple

as we can possibly make it.

Page 15: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 15

Pseudocode-The Building BlocksThe 3 most important statements are:

input statements - readoutput statements - writeassignment statements - set (to store values in

memory)

Other 2 statements control flow of a program They control which input, output and assignment

statements are performed by the program

They control the number of input, output and assignment statements performed by the program

Page 16: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 16

Example Pseudocodewrite “Number of marks in exam ==> “ read M1 write “Student’s mark ==> “read M2set M3 to M2 / M1set M4 to 100 * M3write “ Student’s percentage: “write M4

More Examples - Refer to Study GuideBook 1, Module 4

Page 17: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 17

Programming Languages The programming languages can be divided

into 3 types.- Machine Languages

- Assembly Languages

- High-level Languages

(C, C++, Pascal, Java, Visual Basic, etc.) Most programs are written in a high-level

language as they are easier to write and understand

The high-level programming language require a COMPILER to convert the high-level language statements to machine code statements

Page 18: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 18

Introduction to C++

History of C++ C++ was evolved from C by Bjarne Stroustrup at Bell

Lab in 1980s C was evolved from B by Dennis Ritchie at Bell Lab in

1972 C uses many features from BCPL & B

Page 19: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 19

A Simple C++ Program//A Simple Program in C++#include <iostream.h>void main (void){

cout <<“welcome to C++”;}

Lets’ take a look at this program

We’ll leave some details to later

There are 6 lines in this program

Page 20: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 20

A Simple C++ Program

Line 1 of the program contains a comment In C++ you can use // or /*comment*/ to insert a

comment It is a good idea to insert comments

Improves program readability Helps other people to understand your program

Line 2 of the program tells the compiler to “include” code, from the “iostream” library, before it is compiled

If this code were not included, the compiler would report an error on Line 5.

It would say: “cout is undefined”

Page 21: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 21

A Simple C++ Program

Line 3 declares the start of main function

A structured program is one that has been broken up into chunks - “functions” in C++

C++ programs contain one or more functions

This program only has one function – the “main” function

Every C++ program must have a “main“ function

Lines 4 and 6 contain left({) and right (}) braces

In C++, we use braces to mark the start and end of a block of code

Page 22: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 22

A Simple C++ Program

Line 5 is the only “executable” line of code herecout <<“welcome to C++”;

This line sends “welcome to C++” to the display

Notice how this line is indentedWe use indentation to make code easier to read

It’s not required by the C++ compiler

cout << “Welcome to C++”; says: write the string of characters Welcome to C++ to the display

Here we use double quotes to mark the start and end of a string of characters

Page 23: COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th

COIT29222 Structured Programming 23

Summary

Contact your local lecturer/tutor for problems

Course profile contains important information

Plagiarism of any kind is NOT permitted

Software development process has 5 steps

You will design, write and test C++ programs

You will use pseudocode to design a program

A compiler translates C++ code into machine code

You will use Visual C++ compiler