CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf...

46
CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE UNIVERSITY, WILBERFORCE, OH 1

Transcript of CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf...

Page 1: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

CPS1192 COMPUTER SCIENCE II

Fall Semester, 2013

CPS1192 COMPUTER SCIENCE II

Fall Semester, 2013

08/27/2013

Lecture 1: OverviewInstructor: Ashraf Yaseen

DEPARTMENT OF MATH & COMPUTER SCIENCECENTRAL STATE UNIVERSITY, WILBERFORCE, OH

1

Page 2: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Outline

Course Administration Course Overview Review of Computer Science I

Introduction to Computers and Programming

Introduction to C++ Expressions and Interactivity Making Decisions Loops and Files

2

Page 3: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Administrivia

Class Web Page http://www.cs.odu.edu/~ayaseen Syllabus

Class Policy Class Notes

Posted before class Read class notes before class

Assignments Posted after class Pay attention to the due dates

Blackboard Posting grades Sending out emails to class

3

Page 4: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Administrivia-cont.

Instructional E-Mail Addresses [email protected]

Instructor: Ashraf Yaseen Office phone: 937-376-6365 Office location: Henderson Hall, 139 Office hours:

M,W,F: 10:00AM-2:00PM T,R: 2:00PM-3:00PM by appointment

4

Page 5: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Administrivia-cont.

Grading Policy

Quizzes will be announced in class

Late Assignment/HW Policy 0~24 hrs: -5% 24~48 hrs: -10% >48 hrs: grade = 0

5

Number

Activities/ Evaluation Methods

Percentages

2 Term Exam 30%

1 Final Exam ( Essay + Final Lab)

30%

16 Lab Assignment/Homework

40%

Class participation and presentation quality will also impact final grade

>=90 A Excellent80-89 B Very Good70-79 C Good60-69 D Passed<60 F Failed

Page 6: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Administrivia-cont.

Textbook Starting out with C++ from Control

Structures through Objects. By Tony Gaddis

Supplies/Materials: Students are encouraged to install Visual

C++ Express on their laptops

6

Page 7: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

CSU Honor Code The Honor Code applies to your conduct in this course. If

you have questions, talk to me

HOMEWORK: All submitted work must be your own Do not copy another student’s work Do discuss material and homework with classmates,

professor If you work with someone, write this on the first page

of your submitted work

EXAMS: Do not give assistance to or receive assistance from anyone but professor

Violations of this Code are treated seriously Evidence of cheating, plagiarism, or unauthorized

collaboration will result in a 0 grade for quiz/assignment/exam May have further consequences

7

Page 8: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

How to get help?

Ask questions in class (or after class) Attend office hours Email me

Make sure that you put “CPS1192” in your subject line

Send it from your .odu account It wouldn’t come to my spam folder

State clearly what you need in your email

8

Page 9: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

How to Get an A in this Class Attendance

Attend class regularly and on time Ask questions Work on in-class exercises and lab

assignments Notes

Read over class notes before class Review class notes after class

Homework Get started as early as possible Contact me if you encounter problems

9

Page 10: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

What You Will Learn

CPS 1192 prepares students for the concept and skill of object-oriented programming (OO).

Topics include class and object, class inheritance, pure virtual function, polymorphism, template function and template class, exception handling, data structure

10

Page 11: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

What You Will Learn-cont.

Upon successful completion of this class, you will be able to define and implement Classes Array of objects Class Inheritance. Pure virtual function and abstract class. Polymorphism. Template function and template class. Exception handling Data structure: stack, queue and linked-list.

11

Page 12: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Topics

C++ programming Overview Classes and Data Abstraction Inheritance and Composition Pointers, Classes, Lists, and Virtual

Functions Overloading and Templates Exception Handling Recursion Linked Lists Searching and Sorting Algorithms Stacks and Queues

12

Page 13: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Importance of This Course

Prerequisite for You must get a C or better to pass

Foundation for advanced courses Operating Systems Programming Language Compiler Design Networking Parallel Programming Algorithm I/O Management

13

Page 14: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

About Me

I got my bachelor’s from JUST (Jordan University of Science & Technology)

Master’s from NYiT (New York Institute of Technology)

Ph.D. (in process) ODU (Old Dominion University)

My Research Computational Biology High Performance Computing

14

Page 15: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

How about you?15

Tell us your name and year

In a few sentences, tell us about you, e.g. Where are you from? What is your major? Career plans or after-college plans? Favorite hobby, sport? Something interesting about yourself

Expectation in this class

Page 16: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Greater Expectations

Class Attendance & Participation: mandatory In-Class exercises/discussion questions

Solidify your understanding

Help gauge your understanding

Increase interactivity (reduce boredom)

You are expected to try your best in class

By attending, you work less out class.

If you miss class, you are responsible for learning what you missed

16

Page 17: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Greater Expectations-cont.

Behave and perform in a professional manner Be punctual, dress appropriately and be

attentive Respect the rights of all participants by turning

off any device that could cause a disturbance during class (this includes pagers, cell phones, personal alarms and iPod music players).

Negative behavior patterns in class (e.g. unexcused absences, tardiness, and class disruptions, wearing hats, eating, drinking, smoking and sleeping) will be treated seriously could result in a reduction of up to 12.5% (labs)

of a student’s final grade.

17

Page 18: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

While in Class,

No Facebook No Cell phone No Music players No Topic unrelated to class. No Sleep No Food No bad jokes

18

Page 19: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Overview of CPS 1192: Programming in C++

19

Page 20: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Chapter 1: Introduction to Computers and Programming

A program is a set of instructions that the computer follows to perform a task

An integrated development environment, or IDE, combine all the tools needed to write, compile, and debug a program into a single software application.

Examples are Microsoft Visual

C++, Turbo C++ Explorer, CodeWarrior, etc

20

Page 21: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

What is a Program Made of?

Common elements in programming languages: Key Words Programmer- Defined Identifiers Operators Punctuation Syntax

21

Page 22: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Chapter 2: Introduction to C++

22

// sample C++ program

#include <iostream>

using namespace std;

int main()

{

cout << "Hello, there!";

return 0;

}

preprocessor directive

comment

which namespace to use

beginning of function named main

beginning of block for main

output statement

end of block for main

string literalsend 0 to operating system

The Parts of a C++ Program

Page 23: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

cout/cin, include

cout/cin cout << "Programming is" << endl;cout << "fun!";

int grade;

cin>>grade;

#include Directive

23

Page 24: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Variables and Literals24

Page 25: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Identifiers25

IDENTIFIER VALID? REASON IF INVALID

totalSales Yes

total_Sales Yes

total.Sales No Cannot contain .

4thQtrSales No Cannot begin with digit

totalSale$ No Cannot contain $

Page 26: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Data Types & Defining Variables

26

Page 27: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Char, String27

Page 28: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Variable Scope28

Page 29: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Chapter 3: Expressions and Interactivity

Cin Object Reads Different Data Types

Mathematical Expressions

Order of Operations

Algebraic Expressions

29

Page 30: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Type Casting30

Page 31: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Combined Assignment Operators

31

Page 32: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Formatting Output

Stream Manipulator

32

Page 33: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

33

Page 34: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Mathematical Library Functions Require cmath header file Take double as input, return a double Commonly used functions:

34

sin Sine cos Cosinetan Tangentsqrt Square rootlog Natural (e) logabs Absolute value (takes and returns an int)

Page 35: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Chapter 4: Making Decisions

Relational Operators >, <, <=, >=, ==, != Do not confuse = and ==

Relational Expressions

The if Statement

35

Page 36: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Expanding if Statement36

Nested if Statements

if/else if Statement

Page 37: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Logical Operators, AND, OR, NOT int x = 12, y = 5, z = -4;

37

(x > y) && (y > z) true

(x > y) && (z > y) false

(x <= z) || (y == z) false

(x <= z) || (y != z) true

!(x >= z) false

Page 38: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

switch Statement38

Page 39: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Chapter 5: Loops and Files39

Page 40: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

While loop40

Page 41: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Do-while41

Page 42: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

For loop42

Page 43: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Nested for Loop

Inner Loop

Outer Loop

Breaking and Continuing a Loop

Page 44: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Using Files for Data Storage44

Page 45: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

Summary

Syllabus Review of CPS1191 Topics

Introduction to Computers and Programming

Introduction to C++ Expressions and Interactivity Making Decisions Loops and Files

Page 46: CPS1192 COMPUTER SCIENCE II Fall Semester, 2013 08/27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.

What I want you to do

Review Chapters 1-5 and Class Slides Prepare for the 2nd part of the review

Chapters 6-8 from CPS1191 Functions Arrays Searching and Sorting Arrays

Enjoy your new semester