1 Lab Session-3 CSIT221 Fall 2002 b Exception Handling b Lab Exercise (Demo Required)

Slides:



Advertisements
Similar presentations
Chapter 16 Exception Handling. What is Exception Handling? A method of handling errors that informs the user of the problem and prevents the program from.
Advertisements

Tinaliah, S. Kom.. * * * * * * * * * * * * * * * * * #include using namespace std; void main () { for (int i = 1; i
Triana Elizabeth, S.Kom. #include using namespace std; void main () { for (int i = 1; i
Lecture 9. 2 Exception  An exception is a unusual, often unpredictable event, detectable by software or hardware, that requires special processing occurring.
1 Week 11 l Basic Exception Handling »the mechanics of exceptions l Defining and Using Exceptions »some "simple" cases l Reality Check »guidelines for.
بسم الله الرحمن الرحيم CPCS203: Programming II. Objectives After you have read and studied this chapter, you should be able to –Improve the reliability.
1 Lab Session-1 CSIT221 Fall 2002 b Refresher slides b Practice Problem b Lab Exercise (Demo Required)
EXCEPTIONS Def: An exception is a run-time error. Examples include: attempting to divide by zero, or manipulate invalid data.
1 Session-16 CSIT 121 Spring 2006 Demo for switch-case due now Demo for switch-case due now String comparison String comparison Slide 23; sample case.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 8 Exception Handling Sections 1-5, 7.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 8 Exceptions Handling.
1 Lab Session-2 CSIT221 Spring 2003 b Intro to Object Oriented Programming b Practice Problem b Lab Exercise (Demo Required)
1 Lab Session-6 CSIT121 Fall 2004 Selection: Operator Precedence Some Q’s and A’s Lab Exercises Additional Practice Questions.
1 Lab-1 CSIT-121 Spring 2005 Lab Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming Exercise.
1 Lab Session-8 CSIT-121 Fall 2003 w Call by Reference w Lab Exercise 1 w Lab Exercise for Demo w Practice Problems.
1 Lab Session-XIV CSIT121 Fall 2000 b Tips for good programming b Complete Lab Exercise 13-B for Using Classes b Work on developing an object oriented.
1 Session-23 CSIT 121 Spring 2006 Revision Ch 7: Reference Parameters Revision Ch 7: Reference Parameters Chapter 8: Value Returning Functions Chapter.
1 Lab Session-9 CSIT221 Fall 2002 Lab Exercise Based on operator overloading (Demo Required)
1 Session-I & II CSIT-121 Spring 2006 Session Targets Introducing the VC++.NET Solving problems on computer Programming in C++ Writing and Running Programs.
1 Lab Session-1 CSIT221 Spring 2003 b Group Programming Challenge b Individual Lab Exercise (Demo Required)
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
OpenMP 3.0 Feature: Error Detection Capability Kang Su Gatlin Visual C++ Program Manager.
1 Session-15 CSIT 121 Spring 2006 Selection with Switch~Case Selection with Switch~Case Need an integer or character to test for Need an integer or character.
1 Lab Session-4 CSIT121 Fall 2004 Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
1 Lab Session-2 CSIT 121 Spring 2005 Debugging Tips NiMo’s Varying Rates Lab-2 Exercise.
1 Lab Session-5 CSIT221 Spring 2003 Default and Parameterized Constructors Destructors Programming Exercise for building a template based class (demo required)
1 Lab Session-3 CSIT121 Fall 2003 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
1 Lab Session-6 CSIT121 Fall 2003 Selection: Operator Precedence Some Q’s and A’s Lab Exercises Additional Practice Questions.
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
1 Lab Session-3 CSIT 121 Fall 2004 Section-3 should finish Lab-1 Exercise first Division rules Operator precedence rules Lab Exercise.
1 Lab Session-9 CSIT-121 Fall 2003 w Random Number Generation w Designing a Game.
1 Lab Session-3 CSIT 121 Spring’05 Division rules Operator precedence rules Lab Exercise.
1 Lab Session-VIII CSIT-121 Fall 2000 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 8 Exception Handling Sections 1-5, 7.
1 Lab Session-11 CSIT 121 Fall 2003 Using arrays in functions Programming Exercise.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
1 Session-9 CSIT 121 Spring 2006 Lab Demo (first 20 minutes) The correct way to do the previous lab sheet Function calls Calling void functions Calling.
1 Lab Session-VIII CSIT-121 Spring 2002 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
McGraw-Hill/Irwin Copyright © 2012 by The McGraw-Hill Companies, Inc. All rights reserved.
Software Solution SOLUTIONS BY OMNI2UACCOUNT Issues on GST and SOLUTIONS BY OMNI2UACCOUNT.
Data Abstraction and Problem Solving with C++ Walls and Mirrors, Third Edition, Frank M. Carrano and Janet J. Prichard ©2002 Addison Wesley CHAPTER 3 Data.
Java Programming Exceptions Handling. Topics: Learn about exceptions Try code and catch Exceptions Use the Exception getMessage() method Throw and catch.
Handling ErrorstMyn1 Handling Errors Up to this point we haven't worried much about errors or exceptions. First, let's distinguish between errors and exceptions.
C++ Exceptions STL Vector. Example int Quotient (int numer, int denom} { if (denom != 0) return (numer/denom); else //What to do?? }
Module 12 Handling Errors in T-SQL Code. Module Overview Understanding T-SQL Error Handling Implementing T-SQL Error Handling Implementing Structured.
1 Lab Session-8 CSIT-121 Spring 2005 Call by Reference Lab Exercise for Demo Practice Problems.
File I/O 11_file_processing.ppt
How do we use the laws of exponents?. The zero power Anything to the power of zero is one.
UNITS AND RECIPE COSTING. OBJECTIVES The student will be able to: Understand how to calculate unit cost Understand and use typical invoices Understand.
UNIT E SELLING FASHION 5.03 Perform various mathematical calculations in retail sales.
1 An Exception is… An unusual, often unpredictable event, detectable by software or hardware, that requires special processing An exception handler is.
1 cuberoot /* Solve f(x) = x*x*x-5 = 0 f'(x) = 3x^2 */ public class cuberoot{ public static void main(String args[]){ double error= ; double x0.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
11. EXCEPTION HANDLING Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
Exception Handling Fall 2008 Dr. David A. Gaitros
Exception Handling SWE 344 Internet Protocols & Client Server Programming.
Exception Handling How to handle the runtime errors.
CSE 1020: Exceptions and A multiclass application Mark Shtern 1-1.
EE4E. C++ Programming Lecture 6 Advanced Topics. Contents Introduction Introduction Exception handling in C++ Exception handling in C++  An object oriented.
Lecture 11 Dr. Eng. Ibrahim El-Nahry Exception Handling.
Asif Nawaz University Institute of Information Technology, PMAS-AAUR Lecture 05: Object Oriented Programming:2014 Object-Oriented Programming in C++ Exception.
Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased.
Requisitions from Stock
Lab Session-9 CSIT-121 Spring 2005
Learning Objectives What else in C++ Bitwise operator
EE422C Software Implementation II
Handling Exceptions.
Module 1: Ratios and Proportional Relationships: Topic C: Ratios and Rates Involving Fractions
Presentation transcript:

1 Lab Session-3 CSIT221 Fall 2002 b Exception Handling b Lab Exercise (Demo Required)

2 Exception Handling b Exceptions are handled by try~catch clauses b Fill in the details to develop a code segment that handles (a) Attempt to divide by zero(a) Attempt to divide by zero (b) Attempt to divide by a negative number(b) Attempt to divide by a negative number (c) Attempt to obtain a result of zero(c) Attempt to obtain a result of zero b Use switch~case to display error as per numeric error code thrown

3 Sample Source Code b #include b #include b using namespace std; b void main() b{b{b{b{ b int fruits,kids; b cout<<“how many bananas?”; b cin>>fruits; b cout<<“how many kids?”; b cin>>kids;

4 Sample Source Code b try b{b{b{b{ b cout<<“Each kid gets “<<fruits/kids<< “bananas”; b}b}b}b} b Catch (int errorcode) b{b{b{b{ b}b}b}b} b}b}b}b}

5 Lab Exercise (Demo Due Sep 17 th Sec 01 and Sep 19 th Sec 02) b Develop an object oriented program to implement a cash register. This cash register stores an inventory of ten items (item numbers 0 through 9). When the item number is given, it can retrieve the invoice price of that item, add 18% profit and show the retail price followed by display of 7% tax and the total price. The program should be able to sell as many items as the user wants. When the program exits, it displays the total amount of sales for the day. The program should be robust and be able to handle any exceptions.