TOURO COLLEGE COURSE SYLLABUS LANDER COLLEGE DEPARTMENT: COURSE TITLE: COURSE NUMBER: COREQUISITE: CREDIT HOURS: DEVELOPER: LAST UPDATE: Computer Science Introduction to Programming MCO 141 MCO 104 3 Debra Morgulis August 19, 2003 COURSE DESCRIPTION This course introduces students to problem solving techniques used in programming. In order to reinforce these concepts in a concrete manner, students will develop numerous programs using the C++ programming language. They will implement programs using input, output and variables and utilize programming control structures such as loops, selection structures, functions, and arrays. COURSE/DEPARTMENTAL OBJECTIVES The students will be able to: Develop algorithms, pseudocode, and/or flowcharts to define solutions that solve simple problems such as Calculating the average, sum or max/min of a group of numbers Calculating net pay for a varying number of employees given each employee’s gross pay, tax rate and other deductions Calculating total interest received given principal, interest rate, and time Calculating account balance given a series of deposits and withdrawals Code, trace, test and debug programs, written in standard C++, that solve simple problems, and include one or more of the following: assignment statements variables arithmetic, logical, relational, conditional operators input/output statements if/else statements switch statement while loops 1 for loops do while loops functions and function calls arrays Define what is meant by common C++ programming terminology such as comments compiler directives data types operators and operator precedence compiling , linking, running, and testing a program library functions interactive input /output constants formatting input / output function parameters pass by value vs. pass by reference function prototypes and type checking header files local variables vs. global variables Differentiate between high-level, assembly languages and machine code COURSE/INSTITUTIONAL OBJECTIVES COURSE CONTENT Introduction to Programming Parts of a C++ Program cout Variables Arithmetic Operators Expressions and Interactivity cin Mathematical Expressions Named Constants Multiple and Combined Assignment Formatting I/O Introduction to File I/O 2 Making Decisions Relational Operators The if Statement The if/else Statement The if/else if Statement Nested if Statements Logical Operators Comparing Strings The Conditional Operator The switch Statement Testing for File Open Errors Looping The Increment and Decrement Operators The while Loop The do-while Loop The for Loop Nested Loops The continue Statement Functions Defining and Calling Functions Function Prototypes Sending Data into a Function Pass by Value Returning a Value from a Function Local and Global Variables Static Local Variables Default Arguments Using Reference Variables as Parameters Overloading Functions The exit( ) Function Arrays One-dimensional Arrays Parallel Arrays Arrays as Function Arguments 3 HARDWARE/SOFTWARE/MATERIALS REQUIREMENTS Software Microsoft Visual C++ Ver. 6.0 Compiler Student data files on network drive Hardware Large Screen Monitor COURSE REQUIREMENTS Approximately 15-20 programming assignments Several written homework exercises Two written exams A cumulative departmental final exam GRADING GUIDELINES A. B. C. D. Students should expect to spend extensive lab time on their own to complete the programming assignments. Students must complete programming assignments in a timely manner or their grades will be lowered. A student who completes all exams, but does not complete all programming assignments, should get at most a TC-. If most of the assignments have not been submitted, the student should receive a TF. Students must take all exams. METHODOLOGY Instructors should introduce each new concept using the whiteboard and referencing the textbook. Programs should be developed in class, together with the students, using the large screen monitor Programs can be traced, as they run, using the on-line debugger provided by the Microsoft Visual C++ compiler. Instructors can then visually show students how loops control the repetition of code, how the control passes to a function when it is called, how an if/else statement controls which section of code is actually executed, and how values inside variables change as the program executes. During the first lessons, approximately 45 minutes should be spent by the students in the lab. The instructor should assign a lab exercise that incorporates the concepts and techniques discussed during the lesson. Students should develop, enter, save, compile and run the 4 programs, asking the instructor for assistance, only when necessary. Instructor should examine the student’s methodology and point out and explain any obvious errors. As the term progresses the amount of material that must be covered may force the instructor to limit the amount of class time devoted to lab exercises. Students who cannot complete lab exercises during the lab time must complete these exercises on their own time. During the latter part of the term, lab exercises will be more complicated and may require several hours of lab time to develop. Written homework assignments should be given that complement the lab programming exercises and that reinforce concepts, such as looping, operator precedence, and decision structures, developed during class. Students should be required to hand in each completed project. The book includes an ample variety of sample exercises and programming assignments. Multiple programming assignments should be assigned per topic, as this is the only way to reinforce the material and develop the students’ programming abilities. An attempt has been made to choose a book that discusses C++ syntax in the context of introducing programming concepts, with an emphasis on problem solving. In order to have sufficient time to cover this course’s curriculum, the instructor must require students to review each week’s lesson by reading the book. In addition, the instructor should assign readings that cover the following week’s lesson so that students are introduced to the concepts before they come to class. Although a lesson plan has been included, instructors should use their own best judgment in determining the amount of time they spend on each topic and the depth of coverage. COURSE TEXTS Title: Standard Version of Starting Out With C++ , Fourth Edition Author: Tony Gaddis Pub. Date: 2003 Publisher: Scott/Jones Inc ISBN: 1-57676-119-3 Supplementary materials included with book: a C++ Programmer’s Handbook CD containing source code for examples in the book and a collection of valuable appendices, Microsoft Visual C++ 6.0 Introductory Edition, and Borland C++ Builder 5. BIBLIOGRAPHY Title: Starting Out With C++ Alternate Second Edition Author: Tony Gaddis Pub. Date: 2001 Publisher: Scott/Jones Inc ISBN: 1-57676-045-6 5 Title: Author: Pub. Date: Publisher: ISBN: C++ Programming: From Problem Analysis to Program Design Davendar Malik 2002 Course Technology 0-619-06213-4 Title: Author: Pub. Date: Publisher: ISBN: Structured & Object-Oriented Problem Solving Using C++, 3rd Edition Andrew C. Staugaard, Jr. 2001 Prentice Hall 0-13-028451-3 Title: Author: Pub. Date: Publisher: ISBN: A Laboratory Course in C++ Nell Dale 2001 Jones and Bartlett 0-7637-0247-1 Title: Authors: Pub. Date: Publisher: ISBN: Problem Solving With C Jacqueline Jones and Keith Harrow 1996 Scott/Jones Inc. 1-881991-48-2 Title: Authors: Pub. Date: Publisher: ISBN: C++ How to Program, Fourth Edition Deitel & Deitel 2002 Prentice Hall 0-13-038474-7 Related Web Sites www.gaddisbooks.com viewed on August 18, 2003 webopedia.internet.com viewed on August 18, 2003 INSTRUCTOR RESOURCE MATERIALS An Instructor’s CD is available containing answers to the even-numbered review questions, solutions for the programming challenges, a test bank, and a collection of PowerPoint slides with lecture notes. Additional Web resources can be found at www.gaddisbooks.com 6 TOPIC ANALYSIS 1. Introduction to Programming Chapter 1 pages 1 – 28 What is a program? An overview of PC hardware components An overview of programming languages Common elements of all programs IPO The programming process Flowcharts Pseudocode 2. A Simple C++ Program Introduce students to the C++ integrated development environment Students should enter, compile, and run a simple C++ program (program can just display student’s name) Assign for homework or review in class the exercises on pp. 23 – 26 3. The Structure of a C++ Program Preprocessor directive - #include main( ) function – introduce special C++ characters Checkpoint: Arranging statements in correct sequence Using cout Using endl Common escape sequences 4. Variables Chapter 2 pages 29 - 39 Chapter 2 pages 39 - 63 Variable declaration / assignment Literals Valid variable names Data types - char, int, float, double, bool Characters vs. Strings sizeof operator Variable scope 7 5. A Closer Look at C++ Program Syntax and Style Chapter 2 pages 64 – 78 Arithmetic operators Comments Programming style – using whitespace Standard vs. Pre-Standard C++ Review concepts with exercises on pp. 73 – 78 6. Developing a Complete Program Chapter 2 pages 78 – 82 Develop a program using an exercise on pp. 78-79 Assign programming assignments from exercises on pp. 78-79 Students should start working on the Serendipity Booksellers Software Development Project: Parts 1 & 2 (In addition to the individual programming assignments, you should assign this ongoing project as a group project to be completed (chaps.1-7) by the end of the semester.) 7. Interactive Data Entry Chapter 3 pages 83 – 91 Using cin Including prompts Reading in strings Declaring character arrays 8. Mathematical Expressions Chapter 3 pages 91 - 116 Operator precedence Conversion of algebraic expressions to C++ Using a library function: pow( ) Omit: Type Conversion (pp. 100 – 101) Omit: Overflow and Underflow (pp. 101 – 103) Type casting const and #define: similarities and differences Multiple assignment: refer to program 3-16 (pp. 112 - 113) Combined assignment operators 9. Formatting Output Chapter 3 pages 117 – 127 Specifying field width using setw( ) 8 Controlling precision using setprecision( ) Including iomanip Formatting decimal numbers with fixed and showpoint manipulators left and right manipulators Little time should be devoted to teaching formatting, as students can basically learn it by themselves 10. Formatting Input Using setw( ) Reading in a string containing spaces using cin.getline( ) Using cin.get( ) to read in a character Using cin.ignore( ) when mixing cin and cin.get( ) Mathematical library functions (students should cover pp. 133 – 137 on their own) 11. Debugging, Problem Solving, & File I/O Chapter 4 pages 167 – 172 Relational operators and expressions True/False Differentiate between = and = = 13. Decision Making Using if and if/else Chapter 3 pages 145 – 166 Hand tracing a program Case study (pp.140 – 143) Introduction to file I/O Assign programming assignments from exercises on pp. 161 – 165 Students should continue working on the Serendipity Project – Part 3 12. Relational Operators Chapter 3 pages 127 - 137 Chapter 4 pages 173 – 194 The if statement Expanding the if statement by using braces The if/else statement The if/else if statement Using a trailing else 9 14. More Uses of if/else if and if Statements Using if/else if to create menus Nested if statements Nested if/else statements 15. Logical Operators Chapter 5 pages 257 – 276 Increment and decrement operators What is a loop? The while loop – a pre-test loop Using counters in loops Keeping a running total Sentinels used to terminate loops Using a loop to read data from a file 18. The do-while and for Loops Chapter 4 pages 222 – 256 The conditional operator The switch statement Using switch statement for building menu systems Testing for file open errors Case study (pp. 236 – 240) Assign programming assignments from exercises on pp. 247 – 253 Students should continue working on the Serendipity Project – Part 4 17. The while Loop Chapter 4 pages 200 – 222 &&, ||, ! Checking numeric ranges Validating user input Comparing strings using strcmp( ) Sorting strings with strcmp( ) 16. More Decision Making Techniques Chapter 4 pages 194 – 200 Chapter 5 pages 276 – 288 The do-while loop – a post-test loop Syntax of the for loop Omitting the for loop’s expressions 10 Multiple initialize and update expressions 19. More Complex Loops Deciding which loop to use Nested loops Breaking out of a loop The continue statement Using loops for data validation 20. Problem Solving Using Loops Chapter 6 pages 322 – 341 Sending values into a function – pass by value Using functions in menu-driven programs The return statement Returning a value from a function Returning a boolean value 23. Functions and Variables Chapter 6 pages 311 – 322 Function definition void functions Calling a function Function prototypes Documenting functions (I recommend using I-P-O comments) 22. Using Functions Chapter 5 pages 295 – 310 Case study (pp. 295 – 300) Assign programming assignments from exercises on pp. 306 – 309 Students should continue working on the Serendipity Project – Part 5 21. Modularization Via Functions Chapter 5 pages 286 – 295 Chapter 6 pages 341 – 352 Local variables Global variables Local and global variables with the same name Static local variables 11 24. More Complex Functions Default arguments Using reference variables as parameters Overloading functions exit( ) function 25. Problem Solving Using Functions Chapter 7 pages 397 – 422 Defining arrays Memory requirements Accessing individual elements Input and output of array contents Array initialization Implicit array sizing Initializing with strings Processing array contents Working with arrays and files 27. Additional Ways to Use Arrays Chapter 6 pages 370 – 396 Stubs and drivers Case study (pp. 372 – 385) Assign programming assignments from exercises on pp. 389 – 393 Students should continue working on the Serendipity Project – Part 6 26. One Dimensional Arrays Chapter 6 pages 352 – 369 Chapter 7 pages 422– 435 Parallel arrays Passing arrays to functions Omit the remaining topics in Chapter 7 (pp. 435 – 466). They will be covered in MCO 232 (Advanced Programming). 12 ATTENDANCE All students are expected to maintain good attendance throughout the course. Instructor must put percentages on all criteria for marks i.e. midterm, final, quizzes, class work, projects and homework assignments. Note: Attendance cannot be used as a criterion to determine a failing final grade. NOTES AND COMMENTS A. All examinations in this course must be closed book. B. Each instructor must create a course outline before the semester begins and hand a copy into the lab tech at that site during the 1st week of class. The instructor must distribute a copy of the course outline to each student on the 1st day of class. 13 SAMPLE OUTLINE SEMESTER/TERM: COURSE NUMBER & NAME: TIME/LOCATION: PREREQUISITE: CREDIT HOURS: PROFESSOR: E-MAIL ADDRESS: TELEPHONE NUMBER (OPTIONAL): CLASS MEETING: 1ST DAY OF CLASS DAYS OF THE WEEK TIME ROOM # LAST DAY OF CLASS HOLIDAYS: NO CLASS 1ST QTR. TEST DATE: 3RD QTR. TEST DATE: FINAL TEST DATE: COURSE DESCRIPTION: ENTRANCE COMPETENCIES: GOALS AND OBJECTIVES: COURSE REQUIREMENTS: COURSE EXPECTATIONS: EXIT COMPETENCIES: PROCEDURE: INSTRUCTOR'S MAKEUP POLICY: TESTS LAB EXERCISES HOMEWORK HOMEWORK ASSIGNMENTS: INSTRUCTOR'S GRADING POLICY/CRITERIA: INSTRUCTOR'S ATTENDANCE POLICY: SCHOOL POLICY CONCERNING INSTRUCTOR ABSENTEEISM: TEXTBOOKS: MATERIALS NEEDED: BIBLIOGRAPHY: RELATED WEB SITES: 14 COURSE OUTLINE: Lesson 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. Topic #1 Introduction to Programming #2 A Simple C++ Program #3 The Structure of a C++ Program #4 Variables #5 A Closer Look at C++ Program Syntax and Style #6 Developing a Complete Program #7 Interactive Data Entry #8 Mathematical Expressions #9 Formatting Output #10 Formatting Input #11 Debugging, Problem Solving, & File I/O Exam #1 #12 Relational Operators #13 Decision Making Using if and if/else #14 More Uses of if/else if and if Statements #15 Logical Operators #16 More Decision Making Techniques #17 The while Loop #18 The do-while and for Loops #19 More Complex Loops #20 Problem Solving Using Loops #21 Modularization Via Functions #22 Using Functions Exam #2 #23 Functions and Variables #24 More Complex Functions #25 Problem Solving Using Functions #26 One Dimensional Arrays #27 Additional Ways to Use Arrays 15