Chapter 1 Program Development Asserting Java © Rick Mercer.

Slides:



Advertisements
Similar presentations
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Advertisements

COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
CS 111: Introduction to Programming Midterm Exam NAME _________________ UIN __________________ 10/30/08 1.Who is our hero? 2.Why is this person our hero?
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
ITEC113 Algorithms and Programming Techniques
Programming Concepts (Part A) Ping Hsu. What is a program? WHITE CAKE RECIPE 1.Preheat oven to 350 degrees F (175 degrees C). 2.Grease and flour a 9x9.
Computer Science 1620 Programming & Problem Solving.
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
While Loops and Do Loops. Suppose you wanted to repeat the same code over and over again? System.out.println(“text”); System.out.println(“text”); System.out.println(“text”);
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
6 Steps of the Programming Process
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
Computer Programming TCP1224 Chapter 2 Beginning the Problem-Solving Process.
Invitation to Computer Science, Java Version, Second Edition.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Lecture 2 Fundamental Data Types. Variable Declaration.
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
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.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
Chapter 1 Program Development Asserting Java © Rick Mercer.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Flowcharts. Problem Solving Computer programs are written to solve problems or perform tasks Programmers translate the solutions or tasks into a language.
Procedural Programming. Programming Process 1.Understand the problem 2.Outline a general solution 3.Decompose the general solution into manageable component.
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
Chapter 5: Control Structures II J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
CS221 Algorithm Basics. What is an algorithm? An algorithm is a list of instructions that transform input information into a desired output. Each instruction.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
REPETITION STATEMENTS - Part2 Structuring Input Loops Counter-Controlled Repetition Structure Sentinel-Controlled Repetition Structure eof()-Controlled.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
The Hashemite University Computer Engineering Department
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
PROBLEM SOLVING. What is a Problem? A problem is a situation that needs to be resolved.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Software Engineering Algorithms, Compilers, & Lifecycle.
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
CompSci 230 S Programming Techniques
A451 Theory – 7 Programming 7A, B - Algorithms.
Software Development Expansion of topics page 28 in Zelle
DDC 1023 – Programming Technique
Chapter 5: Control Structures II
Repetition-Counter control Loop
Chapter 1 Program Development
Introduction to pseudocode
Coding Concepts (Basics)
Algorithm and Ambiguity
Chapter 1 Problem Solving with C++
Chapter 2 – part a Brent M. Dingle Texas A&M University
Presentation transcript:

Chapter 1 Program Development Asserting Java © Rick Mercer

Outline  Goals – Understand an example of program development – Understand the characteristics of a good algorithm – Understand how algorithmic patterns can help design programs

Program Development  One program development strategy has these three steps: Analysis:Understand the problem Design: Organize the solution Implementation:Get the solution running  Program development is the progression from analysis to design to implementation  We'll see deliverables from all three phases deliverable : An item that indicates progress was made

Deliverables  Analysis deliverable – A document that lists the variable names and a sample problem  Design deliverable – An algorithm that outlines a solution  Implementation deliverable – An executable program

Analysis  Synonyms for analysis – inquiry, examination, study  Activities – Read and understand the problem statement. – Name the pieces of information necessary to solve the problem ♦ these data names are part of the solution

Problem  Need a program to compute the course grade Name the data needed to compute an answer 1. ___________________ 2. ____________________ 3. ____________________ 4. ____________________ 5. ____________________ 6. ____________________ Name the data to store an answer 1. _____________

There is more to data than just names  The data are stored in variables  Each variable that stores numeric data – has a name – has a value – can be used in a variety of operations such as ♦ storing different values into the variable ♦ multiply *, divide /, add +, and subtract ♦ retrieve the value to be used in expressions ♦ display the value

To input or output?  It help in the early programs if data is distinguished either as input or as output Output Information the computer must display after the processing has occurred Input Information the user must supply to solve the problem.

Sample problems help  It helps to provide sample problems – given specific input data, determine the output Problem : Find wholesale price given the markup and retail prices Sample Problem 1 markup 0.5 Input (0.5 represents 50%) retailPrice Input wholesalePrice Output Sample Problem 2 markup 1.0 Input (1.0 represents 100%) retailPrice Input wholesalePrice Output`

Summary of Analysis  Things to do during analysis – Read and understand the problem – Pick variable name that represent the answer ♦ This is the output – Decide what data the user must enter to get the answer—the input (the unknowns) – Create a document that summarizes the analys is

Other Problems as Analysis Deliverables

Design  Synonyms of design: model, think, plan, devise, pattern, propose, outline  We'll use these design tools: – algorithms – algorithmic patterns – algorithm walkthroughs

Algorithms  An algorithm is a set of activities that solves a problem  An algorithm must: – list activities that must be performed – list the activities in the proper order

Algorithm to Bake a Cake  A recipe (a.k.a. an algorithm) – Preheat Oven – Grease Pan – Mix ingredients – Place ingredients into pan – place pan in oven – remove pan after 35 minutes  Switch some activities around... what happens if …

Algorithmic Patterns  Pattern: Anything shaped or designed to serve as a model or guide in making something else.  Algorithmic Pattern: – Serves as a guide to help develop programs – It represents a common type of action that occurs over and over again in programs – A solution that can be used different contexts  Th e Input/Process/Output (IPO) Pattern can be used. – This IPO pattern will be used in our first project

IPO Algorithmic Pattern Pattern:Input/Process/Output (IPO) Problem:The program requires input data to generate the desired information Outline:1. obtain input data from user 2. process input data 3. output the results

Patterns ala Alexander " Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice." From A Pattern Language, Christopher Alexander, Oxford University Press, 1977

Example of Algorithm Design  The design deliverable will be an algorithm  The IPO patterns provides a guide to design a more specific algorithm (that is a bit sketchy): IPO ModelIPO applied to Chapter 1 Case Study I)nput Obtain the items that count for 127A's P)rocess Compute the course grade O)utput Display the course grade

Refining Activities in algorithms  We often need to refine one or more activities (algorithm steps). – For example, Compute the course grade might now be refined with the mathematical addition + and multiplication * symbols

Implementation  Synonyms for Implementation – accomplishment, making good, execution  Implementation deliverable: computer program

Example Translations  Here are some pseudocode algorithm step translated into the Java programming language – Display the value of courseGrade System.out.println("Course grade: " + courseGrade); – Obtain test1 Tell user what you want, then "read" it in Scanner keyboard = new Scanner(System.in); System.out.print( "Enter test one: " ); int test1 = keyboard.nextDouble();  Code Demo: Implement the Java Program

compile, correct, run, test, compile, correct run, test, correct, run, test, test, test...  Once the algorithm is translated into a programming language abstraction: – use the compiler to generate byte code ♦ you will have errors so you'll need to fix errors, compile, and repeat until there are no compiletime errors – use the Java virtual machine to execute program – test the program ♦ run the program several times with different sets of input data based on sample problems from analysis ♦ compare program output to expected results – fix program if it doesn't work

Testing  Testing occurs at any point in program development: Analysis:sample problems Design:algorithm walkthroughs Implementation:run program with several sets of input data  A running program isn't always right – however, testing provides confidence that it works correctly

Some test cases  All inputs equal 90, 90, 90, 90, 90, 90 – should be what? ________  All different 100, 90, 80, 70, 60, 50 – should be? ___  First two equal, but different from rest  First and second are equal, different from rest  First and third are equal, different from rest  Negatives? Ah, let's assume valid input.