The Software Lifecycle. Example Problem: Update a Checkbook Write a program that allows the user to enter a starting balance, a transaction type, D or.

Slides:



Advertisements
Similar presentations
Credit hours: 4 Contact hours: 50 (30 Theory, 20 Lab) Prerequisite: TB143 Introduction to Personal Computers.
Advertisements

User-Defined Functions Like short programs Can operate on their own data Can receive data from callers and return data to callers.
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Problem Solving and Program Design. COMP104 Problem Solving / Slide 2 Our First Program // a simple program #include using namespace std; int main() {
Three types of computer languages
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Computer Science 1620 Programming & Problem Solving.
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
Guide To UNIX Using Linux Third Edition
Program Input and the Software Design Process ROBERT REAVES.
Basic Elements of C++ Chapter 2.
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Software Engineering 1 (Chap. 1) Object-Centered Design.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
COMPUTER SCIENCE I C++ INTRODUCTION
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Input, Output, and Processing
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Fundamental Programming: Fundamental Programming Introduction to C++
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Program Development C# Programming January 30, 2007 Professor J. Sciame.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
The Hashemite University Computer Engineering Department
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 2021 Software Development. CMSC 2022 Software Development Life Cycle Five phases: –Analysis –Design –Implementation –Testing –Maintenance.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Problem Solving and Program Design. Problem Solving Process Define and analyze the problem. Develop a solution. Write down the solution steps in detail.
Chapter 1: Introduction to Computers and Programming
Basic concepts of C++ Presented by Prof. Satyajit De
Chapter Topics The Basics of a C++ Program Data Types
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Chapter 1: Introduction to computers and C++ Programming
Basic Elements of C++.
Objectives Identify the built-in data types in C++
Basic Elements of C++ Chapter 2.
Chapter 1: Introduction to Computers and Programming
Designing and Debugging Batch and Interactive COBOL Programs
Writing Your First C++ Programs
Chapter 3: Input/Output
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
A programming language
Software Development Process
FOR statement a compact notation for a WHILE e.g. sumgrades = 0;
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Presentation transcript:

The Software Lifecycle

Example Problem: Update a Checkbook Write a program that allows the user to enter a starting balance, a transaction type, D or W, and a transaction amount. The program should perform the given operation (deposit or withdraw) and display the results.

Sample User Interaction with the Program Enter the starting balance and press : Enter the transaction type (D) deposit or (W) withdrawal and press : D Enter the transaction amount and press : Starting Balance $ Transaction $75.00 D Ending Balance $310.16

Sample User Interaction with the Program Enter the starting balance and press : Enter the transaction type (D) deposit or (W) withdrawal and press : W Enter the transaction amount and press : Starting Balance $ Transaction $65.75 W Ending Balance $244.41

Analysis Analysis describes what needs to be done to solve a problem, not the details of how that is done We can use structure charts or module specifications

Structure Chart for Top-Down Analysis Main Task Subtask 1Subtask 2Subtask 3

Structure Chart for The Checkbook Problem Update checkbook Get Information Perform Computations Display Results

Second-Level Refinement Update checkbook Get Information Perform Computations Display Results Get Starting Balance Get Transaction Type Get Transaction Amount

Analysis: Specify Module, Task, Inputs, and Outputs Module: Get information Task: Have the user enter information from the keyboard Outputs: starting balance transaction type transaction amount

Analysis: Specify Module, Task, Inputs, and Outputs Module: Perform computations Task: If the transaction is a deposit add it to the balance else subtract it from the balance Inputs: starting balance transaction type transaction amount Outputs: ending balance

Analysis: Specify Module, Task, Inputs, and Outputs Module: Display results Task: Display the results in readable form Inputs: starting balance transaction type transaction amount ending balance

Design Receives the results of analysis Describes how a module accomplishes its solution Concern is with logic

Pseudocode Pseudocode is a high-level, non-executable notation for describing designs Pseudocode language forms resemble those of most programming languages but are easier to read Concern is with logic, not syntax

Design: Pseudocode for the Top-Level Task 1. Get information 2. Perform computations 3. Display results

Second-Level Refinement 1. Get information 1.1 get starting balance 1.2 get transaction type 1.3 get transaction amount 2. Perform computations 2.1 if deposit then add amount to balance else subtract amount from balance 3. Display results 3.1 display starting balance 3.2 display transaction type 3.3 display ending balance

Implementation (Coding) Receives the results of design One design can be coded in many different programming languages Concern is with syntax or correct form of code

Steps in Coding Edit the program Compile the program Run the program Syntax errors Run-time and logic errors

The Parts of a C++ Program Preprocessor directives (to include libraries) Main function –data declarations –program statements

Program Comments // Program file: chbook.cpp // This program updates a checkbook. Not executable, but describes the task of the program for the reader.

Preprocessor Directives // Program file: chbook.cpp // This program updates a checkbook. #include Ask the compiler to include library code for the program. These libraries contain code for input and output operations.

The main Function // Program file: chbook.cpp // This program updates a checkbook. #include int main() { return 0; } This program actually does nothing, but well include the code for the checkbook program shortly.

Declare Data Variables int main() { double startingBalance, endingBalance, transAmount; char transType; Each data variable has a name and a type. Type double is for numbers with a decimal point. Type char is for letters and other keyboard characters.

Declare Data Variables int main() { double startingBalance, endingBalance, transAmount; char transType; C++ is case sensitive. TransType is a different name than transType. Use names that describe roles of data in the program.

Code the Module for Getting Data int main() { double startingBalance, endingBalance, transAmount; char transType; // Module for getting the data. cout : "; cin >> startingBalance; cout << "Enter the transaction type (D) deposit or (W) withdrawal "; cout : "; cin >> transType; cout : "; cin >> transAmount; Dont worry about understanding all these statements; we will cover them in detail shortly.

Code the Module for Performing Computations int main() { double startingBalance, endingBalance, transAmount; char transType; // Module for getting the data (now hidden) // Module for performing computations. if (transType == 'D') endingBalance = startingBalance + transAmount; else endingBalance = startingBalance - transAmount;

Code the Module for Displaying Results int main() { double startingBalance, endingBalance, transAmount; char transType; // Module for getting the data (now hidden) // Module for performing computations (now hidden) // Module for displaying results. cout << setiosflags(ios::fixed | ios::showpoint | ios::right) << setprecision(2); cout << endl; cout << "Starting balance $" << startingBalance << endl; cout << "Transaction $" << transAmount << " " << transType << endl; cout << "Ending balance $" << endingBalance << endl; return 0; }

Testing Receives the results of coding Must check to see that the program produces the expected output for any given input Cannot be exhaustive; must use typical inputs and limiting cases (such as 0)