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.

Slides:



Advertisements
Similar presentations
An Introduction to Programming with C++ Fifth Edition Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Advertisements

 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
CMT Programming Software Applications
Introduction to Computers and Programming Lecture 3: Variables and Input Professor: Evan Korth New York University.
Chapter 2: Input, Processing, and Output
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Programming.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Computer Programming 2 Lab(1) I.Fatimah Alzahrani.
Week 1 Algorithmization and Programming Languages.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
VARIABLES Programmes work by manipulating data placed in memory. The data can be numbers, text, objects, pointers to other memory areas, and more besides.
1 Program Planning and Design Important stages before actual program is written.
Chapter 2: Introduction to C++. Language Elements Keywords Programmer-defined symbols (identifiers) Operators Punctuation Syntax Lines and Statements.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
JavaScript 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
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.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
COP 2551 Introduction to Object Oriented Programming with Java Topics –Introduction to the Java language –Code Commenting –Java Program Structure –Identifiers.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Elementary Programming.
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
Chapter 1.2 Introduction to C++ Programming
Introduction to Computers and C++ Programming
Chapter Topics The Basics of a C++ Program Data Types
Elementary Programming
Completing the Problem-Solving Process
Chapter 2 Elementary Programming
Basic Elements of C++.
The Selection Structure
Introduction to Scripting
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.
Java Programming: From Problem Analysis to Program Design, 4e
Basic Elements of C++ Chapter 2.
Introduction to C++ Programming
مساق: خوارزميات ومبادئ البرمجة الفصل الدراسي الثاني 2016/2015
MSIS 655 Advanced Business Applications Programming
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
Chapter 2: Input, Processing, and Output
Chapter 2 Primitive Data Types and Operations
Chapter 1 c++ structure C++ Input / Output
CHAPTER 6 Testing and Debugging.
Presentation transcript:

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 3

Coding the Algorithm into a Program Problem Specification: Create a program that prompts the user for two integers, adds the two numbers together, then displays the result. 3

IPO Chart for the Floating Point Adder 3 InputProcessingOutput first number second number Processing items: none Algorithm: 1. enter the first number and the second number 2. calculate the sum by adding the first number to the second number 3. display the sum sum

Assigning Names, Data Types, and Initial Values to the IPO Items §Programmers use the information in the IPO chart to code the algorithm §First, the programmer assigns a descriptive name to each unique input, processing, and output item listed in the IPO chart §In most programming languages, these names can contain only letters, numbers, and the underscore; they cannot contain punctuation characters or spaces §Most Java programmers use lowercase letters for the names, capitalizing the first letter of subsequent words if necessary 3

Assigning Names, Data Types, and Initial Values to the IPO Items §The programmer also assigns a data type to each input, processing, and output item §The data type specifies the type of data each item represents §In addition to assigning both a name and data type to each input, processing, and output item, the programmer also assigns an initial value §This is referred to as initializing the item §Variables are simply computer memory locations that the program will use while running 3 4

Assigning Names, Data Types, and Initial Values to the IPO Items 3 IPO Chart InformationJava instructions Input first number second number Processing Output sum Algorithm 1. enter the first number and the second number 2. calculate the sum by adding the first number to the second number 3. display the sum int firstNumber = 0; int secondNumber = 0; int sum = 0;

Assigning Names, Data Types, and Initial Values to the IPO Items  The word double, which must be typed using lowercase letters, is a keyword in Java §A keyword is a word that has a special meaning in a programming language §Notice that each of the variable declaration instructions ends with a semicolon (;) §The instruction to declare a variable is considered a statement, which is simply a Java instruction that causes the computer to perform some action after it is executed, or processed, by the computer §All Java statements must end with a semicolon 3

Translating the Algorithm Steps into Java Code §After assigning a name, data type, and initial value to each input, processing, and output item, the programmer then translates each step in the algorithm into one or more Java instructions §In Java, you use streams, which are just sequences of characters, to perform standard input and output operations  The standard output stream is called System.out which refers to the computer screen 3

Translating algorithm steps into Java Code 3 IPO Chart InformationJava instructions Input first number second number Processing Output sum Algorithm 1. enter the first number and the second number int firstNumber = 0; int secondNumber = 0; int sum = 0; Scanner in = new Scanner(System.in); System.out.print(“Enter first integer: ”); firstNumber = in.nextInt(); System.out.print(“Enter second integer: ”); secondNumber = in.nextInt();

Translating algorithm steps into Java Code 3 IPO Chart InformationJava instructions 2. calculate the sum by adding the first number to the second number 3. display the sum sum = firstNumber + secondNumber; System.out.println(“The sum total is ” + sum);

Desk-Checking the Program §Desk-check every program to make sure that each step in the algorithm was translated correctly 3

Evaluating and Modifying the Program §The final step in the problem-solving process is to evaluate and modify (if necessary) the program §Programmers often refer to this as the “testing and debugging” step §Testing refers to running (executing) the program, along with sample data, on the computer §Debugging refers to the process of locating and removing any errors, called bugs, in a program 3

Evaluating and Modifying the Program §Program errors can be either syntax errors or logic errors §You create a syntax error when you enter an instruction that violates the programming language’s syntax §Logic errors, on the other hand, are much more difficult to find, because they can occur for a variety of reasons 3