COS120 Software Development Using C++ AUBG Fall semester 2010

Slides:



Advertisements
Similar presentations
Introduction to Programming in C++ John Galletly.
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Chapter 2- Visual Basic Schneider
The Program Development Cycle and Program Design Tools
Chapter 2: Input, Processing, and Output
Introduction to C++ Programming CS 117 Section 2 and KNET Sections Spring 2001 MWF 1:40-2:30.
Chapter 1: An Overview of Computers and Programming Languages
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Software Engineering 1 (Chap. 1) Object-Centered Design.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CS1044 – Intro. To Programming in C++ Dr. Craig A. Struble.
CS 115 Chapter 1 Overview of Programming and Problem Solving.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers, Problem Solving, and Programming Problem.
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
1 Chapter 1 - An Introduction to Computers and Problem Solving 1.1 An Introduction to Computers 1.2 Windows, Folders, and Files 1.3 Program Development.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
CS 0004 –Lecture 8 Jan 24, 2011 Roxana Gheorghiu.
Lecture 9m: Top-Down Design with Functions COS120 Software Development Using C++ AUBG, COS dept.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Chapter 4 Programming Concepts Dept. of Computer Engineering Khon Kaen University.
Problem Solving and Program Design in C (5th Edition) by Jeri R. Hanly and Elliot B. Koffman CPCS 202 Chapter 2 – Input/Output
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
Chapter 2 - VB.NET by Schneider1 Chapter 2 - Problem Solving Program Development Cycle Programming Tools.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Lecture 6: Computer Languages. Programming Environments (IDE) COS120 Software Development Using C++ AUBG, COS dept.
Overview of Programming and Problem Solving Textbook Chapter 1 1.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Problem Solving and Program Design in C (5th Edition) by Jeri R. Hanly and Elliot B. Koffman Chapter 1 (Software Development Method) © CPCS
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
Software Development Method Reference : Problem Solving & Program Design in C ; Jeri R.Hanly, Elliot B.Koffman.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
The Hashemite University Computer Engineering Department
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALMAJMA'AH UNIVERSITY College of Science and Humanitarians Studies in Alghat Management Information System Section (211 NMA course) Introduction to Programming.
Introduction to Computers and C++ Programming
Chapter 2- Visual Basic Schneider
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Chapter 2- Visual Basic Schneider
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Chapter 2- Visual Basic Schneider
Understanding Problems and how to Solve them by using Computers
Basic Concepts of Algorithm
Presentation transcript:

COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot Koffman, http://www.aw.com/cssupport Course lecturer: Assoc. Prof. Stoyan Bonev, PhD

Lecture 2: Introduction to Computers, Problem Solving and Programming (continued)

Lecture Contents: Software Development Method (Software Life Cycle) – reminder and further explanations; Illustration of applying IPO model of computing process; Applying the SDM for solving problems based on linear and branch algorithms

Software Development Method – Software Life Cycle – Program Development Cycle Version 1: ·        Specify the problem requirements; ·        Analyze the problem; ·        Design the algorithm to solve the problem; ·        Implement the algorithm; ·        Test and verify the completed program; ·        Maintain and update the program. 

Software Development Method – Software Life Cycle – Program Development Cycle  Version 2: ·        Systems Analysis; ·        Systems Design; ·        Systems Implementation; ·        Systems Support.

Software Development Method – Software Life Cycle – Program Development Cycle Version 3: Analyze: Define the problem Design: Plan the solution to the problem Choose the interface: Select text boxes, buttons, etc Code: Translate the algorithm into a Prog Lan like C/C++ or C# or Java or VBasic Test & Debug: Locate and remove any errors in program Complete Documentation: Organize program description

Software Development Method – Software Life Cycle – Program Development Cycle Simplified Version 4 (as in E.Petroutsos, pp28): Decide what the application will do and how it will interact with the user. Design the application’s user interface according to requirements of step 1. Write the actual code behind the events you want to handle.

Software Development Method Problem Analysis - (Correct Problem) Identify data objects Determine Input/Output data Constraints on the problem Design Decompose into smaller problems Top-down design (divide and conquer) Develop Algorithm (Desk check)

Software Development Method Implementation Writing the algorithm Testing Verify the program meets requirements System and Unit test Documentation Key part in the development process

Algorithm definitions Definition 1: A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time Definition 2: A procedure for solving a problem in terms of 1.   the actions to be executed, and 2.  the order in which these actions are to be executed is called an algorithm. Definition 3: An algorithm is a list of steps for solving a problem.

How to document algorithms? Three “notations” used to document algorithms: • Flowchart • Pseudo code • Hierarchy chart

Flowchart Also named a control-flow diagram Graphically depicts the logical steps to carry out a task and show how the steps relate to each other. Uses a set of graphic symbols to indicate what should happen at any stage in the algorithm.

Flowchart symbols

Flowchart symbols

Flowchart example

Pseudo code Uses English-like phrases with some C/C++ terms to outline the program

Hierarchy charts Show how the different parts of a program relate to each other Hierarchy charts may also be called: Structure charts HIPO (Hierarchy plus Input-Process-Output) charts Top-Down charts VTOC (Visual Table of Contents) charts

Comments When tracing a flow chart, start at the start symbol and follow the flow lines to the end symbol. Testing an algorithm at the design stage is known as desk checking. Flowcharts, pseudo code, and hierarchy charts are program planning tools that are not dependent on the programming language being used.

Applying the Software Development Method Stage: Analyze the Problem Stage: Design the algorithm IPO model of a computing process I - Input P - Process O - Output

Applying the Software Development Method Attention: Analyze the problem and design the algorithm: It is helpful to underline phrases in the problem statement that identify input and output. See the example below: Problem: Compute and display the total cost of apples given the number of kilos of apples purchased and the cost per kilogram of apples.

Applying the Software Development Method Problem: Compute and display the total cost of apples (output) given the number of kilos of apples purchased and the cost per kilogram of apples.

Applying the Software Development Method Problem: Compute and display the total cost of apples (output) given the number of kilos of apples (input-1) purchased and the cost per kilogram of apples.

Applying the Software Development Method Problem: Compute and display the total cost of apples (output) given the number of kilos of apples (input-1) purchased and the cost per kilogram of apples (input-2).

Applying the Software Development Method Problem: Compute and display the total cost of apples (output) given the number of kilos of apples (input-1) purchased and the cost per kilogram of apples (input-2).

Applying the Software Development Method (cont.) Problem input: quantity of apples purchased (in kg) cost per kilo of apples (in $ or in BGN) Problem output:     total cost of apples (in $ or in BGN) After specifying inputs and outputs, develop list of formulas, giving relationship between input and output. Abstract form: Total cost = Unit cost * Number of units Detailed, concrete form: Total_cost_of_apples = Cost_per_kg * Kilos_of_apples

Abstract form of the algorithm . Begin Enter Input Data Apply formula or a list of formulas Display Result End

Abstract form of the algorithm 0. Naming memory locations to store input data, intermediate values and final results Begin Enter Input Data Apply formula or a list of formulas Display Result End

Concrete form of an algorithm 0. We need three memory cells: to store two input values and one for the result. We’ll use names QantityOfApples, CostPerKilo, and TotalCost Begin Enter data and store in QuantityOfApples, CostPerKilo TotalCost = QuantityOfApples * CostPerKilo; Display contents of TotalCost End

Applying the Software Development Method Case Study:Converting Miles to Kilometers Problem  Your job requires you to study some maps that give distances in kilometers and some that use miles. You prefer to deal in metric measurements. Write a program that performs the necessary conversion.

Applying the Software Development Method Analysis  The first step in solving this problem is to determine what you are asked to do. You must convert from one system of measurement to another, but are you supposed to convert from kilometers to miles, or vice versa? The problem states that you prefer to deal in metric measurements, so you must convert distance measurements in miles to kilometers.

Applying the Software Development Method Design  The next step is to formulate the algorithm that solves the problem. Begin by listing the three major steps, or sub problems of the algorithm. Implementation  To implement the solution, you must write the algorithm as a C++ program. Testing  How do you know the sample run is correct?

Problem: Converting Miles to Kilometers Problem formulated: Design an algorithm and develop a program to convert miles to kilometers.

Problem: Converting Miles to Kilometers Underline phrases to identify input and output Design an algorithm and develop a program to convert miles (input) to kilometers (output). Input: miles Output: kilometers

Problem: Converting Miles to Kilometers Develop a formula or a list of formulas, giving relationship between input and output 1 mile is equivalent to 1,609 kilometers 1 mile = 1.609 km const float KMS_PER_MILE = 1.609; #define KMS_PER_MILE 1.609

Problem: Converting Miles to Kilometers Reminder: Abstract form of the algorithm 0. Naming memory locations to store input data, intermediate values and final results Begin Enter Input Data Apply formula or a list of formulas Display Output Result End

Problem: Converting Miles to Kilometers Reminder: Abstract form of the algorithm 0. Naming memory locations to store input data, intermediate values and final results Begin Enter Input Data Apply formula or a list of formulas Display Output Result End Applying naming conventions: we need 2 mnemonic names (identifiers): For the input data we’ll use name miles. For the result value we’ll use name kms.

Problem: Converting Miles to Kilometers Final version of the concrete algorithm 0. Naming conventions: miles for miles, kms for kilometers Begin Enter value for miles (store input data into miles). Calculate kilometers multiplying miles by 1.609 and save result (store into kms) Apply formula: kms = 1.609 * miles; Output Result (contents of kms displayed on screen). End

Problem: Converting Miles to Kilometers Describe the algorithm Converting miles to kilometers using a flowchart Also named a control-flow diagram

Problem: Converting Miles to Kilometers

Problem: Converting Miles to Kilometers Describe the algorithm Converting miles to kilometers using pseudo code Uses English-like phrases with some C/C++ terms to outline the program

Problem: Converting Miles to Kilometers 1. Read the number of miles 2. Set the number of kilometers to 1.609 * miles 3. Display the number of kilometers

Problem: Converting Miles to Kilometers Describe the algorithm Converting miles to kilometers using a hierarchy chart Show how the different parts of a program relate to each other

Problem: Converting Miles to Kilometers

The source text of a C++ program Implementing algorithm Open the handout file: look at page 2 The source text of a C++ program Implementing algorithm CONVERT MILES TO KILOMETERS

Exercise 2.1 Apply the SDM and build a linear algorithm: Problem: Converting feet and inches to meters

Exercise 2.2 Apply the SDM and build a linear algorithm: Problem: To add, subtract, multiply and divide two numeric values

Exercise 2.3 Apply the SDM and build a branch algorithm: Problem:  Root (solution) of a linear equation bx + c = 0

Exercise 2.3 Apply the SDM and build a branch algorithm: Problem:  Root (solution) of a linear equation bx + c = 0 (single solution x = -c/b, infinite number of solutions, no solution);

Exercise 2.4 Apply the SDM and build a branch algorithm: Problem: Roots (solution) of a quadratic equation ax2 + bx + c = 0 (two distinct solutions, two identical solutions, no real solutions).

Friedman/Koffman, Chapter 01 Before lecture end Lecture: Problem Solving More to read: Friedman/Koffman, Chapter 01 Or Coming approx. 10 slides

Chapter 1: Introduction to Computers, Problem Solving, and Programming Abstraction, and Design using C++ 5e by Frank L. Friedman and Elliot B. Koffman

1.5 Software Development Method Problem Analysis Identify data objects Determine Input / Output data Constraints on the problem Design Decompose into smaller problems Top-down design (divide and conquer) Develop Algorithm (Desk check) Algorithm refinement

Software Development Method Implementation Converting the algorithm into programming language Testing Verify the program meets requirements System and Unit test Maintenance All programs undergo change over time

1.6 Applying the Software Development Method Case Study: Converting Miles to Kilometers Problem  Your summer surveying job requires you to study some maps that give distances in kilometers and some that use miles. You and your coworkers prefer to deal in metric measurements. Write a program that performs the necessary conversion.

Data Requirements Problem Input miles distance in miles Problem Output kms the distance in kilometers Relevant Formula 1 mile = 1.609 kilometers

Design Formulate the algorithm that solves the problem. Algorithm 1. Get the distance in miles. 2. Convert the distance to kilometers. 3. Display the distance in kilometers. Algorithm Refinement 2.1 The distance in kilometers is 1.609 the distance in miles Desk check!

Listing 1.2 Miles to kilometers

Implementation #include <iostream> using namespace std; int main( ) { const float KM_PER_MILE = 1.609; float miles, kms; cout << “Enter the distance in miles: “; cin >> miles; kms = KM_PER_MILE * miles; cout << “The distance in kilometers is “ << kms << endl; return 0; }

Testing Test with input data for which you can easily determine the expected results E.g. 10 miles should convert to 16.09 kilometers

Thank You For Your Attention