This set of slides is provided by the author of the textbook1 Introductory Topics (Continued) l Computer Components l Basic Control Structures l Problem.

Slides:



Advertisements
Similar presentations
Overview of Programming and Problem Solving ROBERT REAVES.
Advertisements

Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
Computer Science-I (CSIT121) Dr. Junaid Ahmed Zubairi SUNY at Fredonia Room 210, Fenton ,
CONTROL STRUCTURES: SEQUENTIAL, SELECTIVE, AND REPETITIVE
1 Chapter 1 Introduction to Object-Oriented Programming.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
This set of slides is provided by the author of the textbook1 Introductory Topics l Computer Programming l Programming Life-Cycle Phases l Creating an.
1 Lecture 19 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Computer Science 1620 Programming & Problem Solving.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems/Headington Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
CS1044 – Intro. To Programming in C++ Dr. Craig A. Struble.
CS 115 Chapter 1 Overview of Programming and Problem Solving.
1 Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
1 Author: Nell Dale Chip Weems Mark Headington Published By Higher Education Press Jones and Bartlett Publishers.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
CSE 1340 Introduction to Computing Concepts Class 2.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
What is a Computer ? Computers are Electronic Machines that process (performs calculation and manipulation) Data under the control of Set of Instructions.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
1 Overview of Programming and Problem Solving Chapter 1.
1 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
1 Chapter 4 Program Input and the Software Design Process CS185/09 - Introduction to Programming Caldwell College.
Overview of Programming and Problem Solving. Objectives In this chapter you will: Learn about different types of computers Explore the hardware and software.
What is programming? Steps to solve a problem. Repeatable by executing or “doing” the steps again. UWP - Landgraf Some slides are from Dr. Qi Yang's notes.
Overview of Programming and Problem Solving Textbook Chapter 1 1.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems/Headington.
Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
Chapter 1 Overview of Programming and Problem Solving 1.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
No I/O is built into C++ l instead, a library provides input stream and output stream KeyboardScreen executing program istreamostream 1.
Copyright © 2003 Prentice Hall, IncSlides created by Bob Koziel.
1 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
Electronic Analog Computer Dr. Amin Danial Asham by.
1 Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
Chapter 1 Overview of Programming and Problem Solving CS185/09 - Introduction to Programming Caldwell College.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Computer Programming (1) Code & No.: CS 102 CREDIT HOURS: 5 UNIT Lecture 3.0 hours/week Lab: 2.0 hour/on every week a. This course introduces the students.
1 Overview of Programming Principles of Computers.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Introduction to Programming By: Prof. Muhammad Abu Baker Siddique 2 nd Lecture 1.
1 Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 1: Introduction to Computers and Programming.
Chapter 1 Overview of Programming and Problem Solving
SOFTWARE DESIGN & DEVELOPMENT
Engineering 1020 Introduction to Programming
Chapter 1 Overview of Programming and Problem Solving
No I/O is built into C++ instead, a library provides input stream and output stream Keyboard Screen executing program istream ostream 1.
What is Computer Programming?
Introduction to Computers
Presentation transcript:

This set of slides is provided by the author of the textbook1 Introductory Topics (Continued) l Computer Components l Basic Control Structures l Problem Solving Strategies l Company Payrolls Example

This set of slides is provided by the author of the textbook2 Computer Components Arithmetic Logic Unit Control Unit Auxiliary Storage Device Memory Unit ( RAM & Registers ) Central Processing Unit ( CPU ) Input Device Output Device Peripherals

This set of slides is provided by the author of the textbook3 Memory Unit l is an ordered sequence of storage cells, each capable of holding a piece of information l each cell has its own unique address the information held can be input data, computed values, or your program instructions.

This set of slides is provided by the author of the textbook4 Central Processing Unit l has 2 components to execute program instructions n Arithmetic/Logic Unit performs arithmetic operations, and makes logical comparisons. n Control Unit controls the order in which your program instructions are executed.

This set of slides is provided by the author of the textbook5 Peripherals l are input, output, or auxiliary storage devices attached to a computer n Input Devices include keyboard and mouse. n Output Devices include printers, video display, LCD screens. n Auxiliary Storage Devices include disk drives, scanners, CD-ROM and DVD-ROM drives, modems, sound cards, speakers, and digital cameras.

This set of slides is provided by the author of the textbook6 Basic Control Structures l a sequence is a series of statements that execute one after another l selection (branch) is used to execute different statements depending on certain conditions l Looping (repetition) is used to repeat statements while certain conditions are met. l a subprogram is used to break the program into smaller units

This set of slides is provided by the author of the textbook7 SEQUENCE Statement...

This set of slides is provided by the author of the textbook8 SELECTION (branch) IF Condition THEN Statement1 ELSE Statement2 Statement1 Statement Statement2 Condition... True False

This set of slides is provided by the author of the textbook9 LOOP (repetition) Statement Condition... False True WHILE Condition DO Statement1

This set of slides is provided by the author of the textbook10 SUBPROGRAM (function) SUBPROGRAM1... SUBPROGRAM1 a meaningful collection of SEQUENCE, SELECTION, LOOP, SUBPROGRAM

This set of slides is provided by the author of the textbook11 Problem Solving Techniques l ASK QUESTIONS -- about the data, the process, the output, error conditions. l LOOK FOR FAMILIAR THINGS -- certain situations arise again and again. l SOLVE BY ANALOGY -- it may give you a place to start. l USE MEANS-ENDS ANALYSIS -- Determine the I/O and then work out the details.

This set of slides is provided by the author of the textbook12 More Problem Solving Techniques l DIVIDE AND CONQUER -- break up large problems into manageable units. (Also called Top-Down Design) l BUILDING-BLOCK APPPROACH -- can you solve small pieces of the problem? l MERGE SOLUTIONS -- instead of joining them end to end to avoid duplicate steps. l OVERCOME MENTAL BLOCK -- by rewriting the problem in your own words.

This set of slides is provided by the author of the textbook13 Company Payroll Case Study A small company needs an interactive program to figure its weekly payroll. The payroll clerk will input data for each employee, and each employee’s wages and data should be saved in a secondary file. Display the total wages for the week on the screen.

This set of slides is provided by the author of the textbook14 One Employee’s Wages In one week employee ID # 4587 works 52 hours at the hourly pay rate of $ Assume a 40.0 hour normal work week and an overtime pay rate factor of 1.5. What are the employee’s wages? 40 x $ = $ x 1.5 x $ = $ ___________ $

This set of slides is provided by the author of the textbook15 Problem-Solving Phase What information will be used? INPUT DATA from outside the program FORMULA CONSTANTS used in program COMPUTED VALUE produced by program OUTPUT RESULTS written to file or screen by program

This set of slides is provided by the author of the textbook16 Problem-Solving Phase INPUT DATAFORMULA CONSTANTS OUTPUT RESULTS Employee ID Number Hourly payRate Hours worked Normal work hours ( 40.0 ) Overtime pay rate factor (1.5) Hourly payRate Hours worked Wages COMPUTED VALUE Wages

This set of slides is provided by the author of the textbook17 If hours are more than 40.0, then wages = (40.0 * payRate) + (hours ) * 1.5 *payRate otherwise, wages = hours * payRate Week’s Wages, in General RECALL EXAMPLE ( 40 x $ ) + ( 12 x 1.5 x $ ) = $

This set of slides is provided by the author of the textbook18 Algorithm for Company Payroll Program l initialize total company payroll to 0.0 l repeat this process for each employee: 1. Get the employee’s ID empNum 2. Get the employee’s hourly payRate 3. Get the hours worked this week 4. Calculate this week’s wages 5. Add wages to total company payroll 6. Write empNum, payRate, hours, wages to file l write total company payroll on screen

This set of slides is provided by the author of the textbook19 // *************************************************** // Payroll program // This program computes each employee’s wages and // the total company payroll // *************************************************** #include // for keyboard/screen I/O #include // for file I/O using namespace std; void CalcPay ( float, float, float& ) ; const float MAX_HOURS = 40.0; // Maximum normal hours const float OVERTIME = 1.5; // Overtime pay factor C++ Program

This set of slides is provided by the author of the textbook20 C++ Code Continued int main( ) { float payRate; // Employee’s pay rate float hours;// Hours worked float wages; // Wages earned float total;// Total company payroll int empNum;// Employee ID number ofstream payFile;// Company payroll file payFile.open( “payfile.dat” );// Open file total = 0.0;// Initialize total

This set of slides is provided by the author of the textbook21 cout << “Enter employee number: “; // Prompt cin >> empNum; // Read ID number while ( empNum != 0 ) // While not done { cout << “Enter pay rate: “; cin >> payRate ; // Read pay rate cout << “Enter hours worked: “; cin >> hours ; // and hours worked CalcPay(payRate, hours, wages); // Compute wages total = total + wages; // Add to total payFile << empNum << payRate << hours << wages << endl; cout << “Enter employee number: “; cin >> empNum; // Read ID number }

This set of slides is provided by the author of the textbook22 cout << “Total payroll is “ << total << endl; return 0 ;// Successful completion } // *************************************************** void CalcPay ( /* in */ float payRate, /* in */ float hours, /* out */ float& wages ) // CalcPay computes wages from the employee’s pay rate // and the hours worked, taking overtime into account { if ( hours > MAX_HOURS ) wages = (MAX_HOURS * payRate ) + (hours - MAX_HOURS) * payRate * OVER_TIME; else wages = hours * payRate; }