Debugging 9/22/15 & 9/23/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.

Slides:



Advertisements
Similar presentations
Chapter 15 Debugging. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Debugging with High Level Languages.
Advertisements

COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Why care about debugging? How many of you have written a program that worked perfectly the first time? No one (including me!) writes a program that works.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
BIM313 – Advanced Programming Techniques Debugging 1.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Introduction to C Programming
A First Program Using C#
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - HelloWorld Application: Introduction to.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
A First Look at Java Chapter 2 1/29 & 2/2 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
More about Java Chapter 2 9/8 & 9/9 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Chapter 2 Variables.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Introduction Chapter 1 1/22/16. Check zyBooks Completion Click on the boxes for each section.
Chapter 2 Wrap Up 2/18/16 & 2/22/16. Topics Review for Exam I DecimalFormat More Style Conventions Debugging using eclipse The Java API.
Harvard Mark I Howard Aiken was a pioneer in computing and a creator of conceptual design for IBM in the 1940s. He envisioned an electro-mechanical computing.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Wrapper Classes Debugging Interlude 1
Chapter 2 Variables.
ME 142 Engineering Computation I
Lecture 1 Introduction Richard Gesick.
Lecture 3: Operators, Expressions and Type Conversion
Chapter 2 - Introduction to C Programming
Eclipse Navigation & Usage.
Testing and Debugging.
Introduction to C# Applications
Computer Programming I
Debugging CMSC 202.
Dialogues and Wrapper Classes
Testing Key Revision Points.
Chapter 2 - Introduction to C Programming
Using Visual Studio with C#
Repetition Chapter 6 12/06/16 & 12/07/16 1 1
Chapter 2 – Getting Started
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 15 Debugging.
Introduction to C++ Programming
Comp 110/401 Appendix: Debugging Using Eclipse
Chapter 2 - Introduction to C Programming
Chapter 1: Computer Systems
MSIS 655 Advanced Business Applications Programming
Branching Chapter 5 11/14/16 & 11/15/
Tonga Institute of Higher Education
Chapter 15 Debugging.
Testing, debugging, and using support libraries
Chapter 2 - Introduction to C Programming
Basic Debugging (compilation)
POS 408 Week 1 Individual Assignment Individual: Console Display Message//tutorfortune.com Click on below link to buy
Chapter 2 - Introduction to C Programming
Unit 3: Variables in Java
Chapter 2 Variables.
Perl Programming Dr Claire Lambert
Introduction to C Programming
Chapter 15 Debugging.
Instructor: Alexander Stoytchev
Chapter 15 Debugging.
Presentation transcript:

Debugging 9/22/15 & 9/23/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010

Exam I Next week. Tu 9/29/15 & W 9/30/15

Objectives Define the terms bug and debugging. Explain what a compile-time error is. Explain what an execution-time error is. Give examples of compile-time errors. Give example of execution-time errors.

Bugs and Debugging Bug Debugging Debugger Any error in a program. Grace Hopper's team logged a "bug" in 1945 Debugging Fixing errors. Debugger Special software to help fix programs. Usually part of IDEs like eclipse.

Syntax Errors Error that keeps the program from compiling. Missing or Extra Semicolons Spelling and Capitalization Missing quote, parenthesis, or braces Missing operators Missing concatenation in println Unintialized Variables Not assigned value Example:DebugSyntax

Execution-Time Errors Logical Errors in a program Examples Incorrect Arithmetic. Divide by zero. Bad input. Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010

Debugging Techniques Visually inspect the code (not every test requires modifying/running the code). Manually set a variable to a value. Insert print statements to observe variable values. Comment out unused code. Example in DebugExecution.java

Using eclipse Debugger Can set breakpoints. Right-click in bar left of code. “Debug as”. Execution stops at breakpoint. Green arrow to continue execution. Can inspect variable contents. “variables” tab Java button to get back to normal mode.

Questions What is the difference between a syntax error and a execution error? Does Java always give helpful error messages? What can you do to help debug execution errors?

Class DecimalFormat Class DecimalFormat enables control of output In java.text package. Specify a string pattern to describe desired format DecimalFormat formatter = new DecimalFormat("0.000"); System.out.println(formatter.format(val));

Class DecimalFormat 0 – digit, leading and trailing zeros # -- digit, no leading and trailing zeros % -- percentage $ -- at beginning displays dollar sign

Class DecimalFormat DecimalFormat

Program Problem Write a program to input a temperature between 30.0 and 40.0 degrees. Output the temperature to the nearest tenth degree My version: DecimalDemo.java

Participation Write a program to input a cash award between $0.00 and $100.00. Use a DecimalFormat to control the output. Output the number to the nearest cent. While writing the program, try setting a breakpoint and inspecting some variables.