CPS1192 COMPUTER SCIENCE II Fall Semester, /27/2013 Lecture 1: Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE UNIVERSITY, WILBERFORCE, OH 1
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
Administrivia Class Web Page 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 s to class 3
Administrivia-cont. Instructional Addresses Instructor: Ashraf Yaseen Office phone: Office location: Henderson Hall, 139 Office hours: M,W,F: 10:00AM-2:00PM T,R: 2:00PM-3:00PM by appointment 4
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 NumberActivities/ Evaluation MethodsPercentages 2Term Exam30% 1Final Exam ( Essay + Final Lab) 30% 16Lab Assignment/Homework40% Class participation and presentation quality will also impact final grade >=90AExcellent 80-89BVery Good 70-79CGood 60-69DPassed <60FFailed
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
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
How to get help? Ask questions in class (or after class) Attend office hours 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 8
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
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
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
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
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
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
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
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
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
While in Class, No Facebook No Cell phone No Music players No Topic unrelated to class. No Sleep No Food No bad jokes 18
Overview of CPS 1192: Programming in C++ 19
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
What is a Program Made of? Common elements in programming languages: Key Words Programmer- Defined Identifiers Operators Punctuation Syntax 21
Chapter 2: Introduction to C++ 22 // sample C++ program #include 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 literal send 0 to operating system The Parts of a C++ Program
cout/cin, include cout/cin cout << "Programming is" << endl; cout << "fun!"; int grade; cin>>grade; #include Directive 23
Variables and Literals 24
Identifiers 25 IDENTIFIERVALID?REASON IF INVALID totalSales Yes total_Sales Yes total.Sales NoCannot contain. 4thQtrSales NoCannot begin with digit totalSale$ NoCannot contain $
Data Types & Defining Variables 26
Char, String 27
Variable Scope 28
Chapter 3: Expressions and Interactivity Cin Object Reads Different Data Types Mathematical Expressions Order of Operations Algebraic Expressions 29
Type Casting 30
Combined Assignment Operators 31
Formatting Output Stream Manipulator 32
33
Mathematical Library Functions Require cmath header file Take double as input, return a double Commonly used functions: 34 sin Sine cos Cosine tan Tangent sqrt Square root log Natural (e) log abs Absolute value (takes and returns an int)
Chapter 4: Making Decisions Relational Operators >, =, ==, != Do not confuse = and == Relational Expressions The if Statement 35
Expanding if Statement 36 Nested if Statements if/else if Statement
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
switch Statement 38
Chapter 5: Loops and Files 39
While loop 40
Do-while 41
For loop 42
Nested for Loop Inner Loop Outer Loop Breaking and Continuing a Loop
Using Files for Data Storage 44
Summary Syllabus Review of CPS1191 Topics Introduction to Computers and Programming Introduction to C++ Expressions and Interactivity Making Decisions Loops and Files
What I want you to do Review Chapters 1-5 and Class Slides Prepare for the 2 nd part of the review Chapters 6-8 from CPS1191 Functions Arrays Searching and Sorting Arrays Enjoy your new semester