Aerospace Software Engineering

Similar documents
Different kinds of resources provided by a package

Introduction to Computers and Programming

Note: The enumerations range from 0 to (number_of_elements_in_enumeration 1).

Motivation. Each distinct type needs its own I/O library INTEGER FLOAT CHARACTER BOOLEAN. Using pure numbers, we can write nonsense:

Example. Section: PS 709 Examples of Calculations of Reduced Hours of Work Last Revised: February 2017 Last Reviewed: February 2017 Next Review:

Scheduling. Scheduling Tasks At Creation Time CHAPTER

In the case above, only the x:= x+1 statement is executed and the result is 4;

Basic Device Management

INFORMATION TECHNOLOGY SPREADSHEETS. Part 1

September 2015 Calendar This Excel calendar is blank & designed for easy use as a planner. Courtesy of WinCalendar.com

Calendar Excel Template User Guide

Institute For Arts & Digital Sciences SHORT COURSES

AIMMS Function Reference - Date Time Related Identifiers

Introduction to Computers and Programming

Math in Focus Vocabulary. Kindergarten

CALENDAR OF FILING DEADLINES AND SEC HOLIDAYS

Calendar PPF Production Cycles Non-Production Activities and Events

typedef int Array[10]; String name; Array ages;

Exercises Software Development I. 02 Algorithm Testing & Language Description Manual inspection, test plan, grammar, metasyntax notations (BNF, EBNF)

ADVANCED ALGORITHMS TABLE OF CONTENTS

Ada LOOP statement allows for repetition of a sequence of statements Three forms of a LOOP statement FOR loop_specification LOOP...

ControlLogix/Studio 5000 Logix Designer Course Code Course Title Duration CCP143 Studio 5000 Logix Designer Level 3: Project Development 4.

Table of Contents 1 Basic Configuration Commands 1-1

MAP OF OUR REGION. About

Complex data structures. Cedric Saule

CSE 305 Programming Languages Spring, 2010 Homework 5 Maximum Points: 24 Due 10:30 AM, Friday, February 26, 2010

name name C S M E S M E S M E Block S Block M C-Various October Sunday

YEAR 8 STUDENT ASSESSMENT PLANNER SEMESTER 1, 2018 TERM 1

Schedule/BACnet Schedule

MAP OF OUR REGION. About

Drawing Courses. Drawing Art. Visual Concept Design. Character Development for Graphic Novels

Arrays. Arrays (8.1) Arrays. One variable that can store a group of values of the same type. Storing a number of related values.

BHARATI VIDYAPEETH`S INSTITUTE OF MANAGEMENT STUDIES AND RESEARCH NAVI MUMBAI ACADEMIC CALENDER JUNE MAY 2017

Year 1 and 2 Mastery of Mathematics

Nortel Enterprise Reporting Quality Monitoring Meta-Model Guide

SYNOPSIS This case study explores building an Ada program to estimate ice thickness.

View a Students Schedule Through Student Services Trigger:

CLOVIS WEST DIRECTIVE STUDIES P.E INFORMATION SHEET

What s next? Are you interested in CompTIA A+ classes?

Cambridge English Dates and Fees for 2018

%Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables

SYNOPSIS This case study looks at the design of a small program to calculate escape velocity from the surface of a moon or planet.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

CSC-140 Assignment 6

2016 Calendar of System Events and Moratoriums

CONFERENCE ROOM SCHEDULER

Sequential Search (Searching Supplement: 1-2)

Arrays. What if you have a 1000 line file? Arrays

Other conditional and loop constructs. Fundamentals of Computer Science Keith Vertanen

ID-AL - SCHEDULER V2.x - Time-stamped & dated programming Scheduler - Manual SCHEDULER. V2.x MANUAL

QI TALK TIME. Run Charts. Speaker: Dr Michael Carton. Connect Improve Innovate. 19 th Dec Building an Irish Network of Quality Improvers

Programming Language. Control Structures: Selection (switch) Eng. Anis Nazer First Semester

1 of 8 10/10/2018, 12:52 PM RM-01, 10/10/2018. * Required. 1. Agency Name: * 2. Fiscal year reported: * 3. Date: *

LAB 4.1 Relational Operators and the if Statement

TEMPLATE CALENDAR2015. facemediagroup.co.uk

CSC 172 Intermediate Progamming

AQA Decision 1 Algorithms. Section 1: Communicating an algorithm

NetworX Series. NX-507E RELAY EXPANDER NX-508E OUTPUT EXPANDER Installation and Startup

Programming Logic and Design Sixth Edition

Table of Contents 1 Basic Configuration Commands 1-1

NetworX Series. NX-507E RELAY EXPANDER NX-508E OUTPUT EXPANDER Installation and Startup

KENYA 2019 Training Schedule

Backup Exec Supplement

EEN118 22nd November These are my answers. Extra credit for anyone who spots a mistike. Except for that one. I did it on purpise.

Chapter 2: Objects and Primitive Data

AP Statistics Assignments Mr. Kearns José Martí MAST 6-12 Academy

Fundamental of Programming (C)

Computer Grade 5. Unit: 1, 2 & 3 Total Periods 38 Lab 10 Months: April and May

Simplified Operating Instructions T105-C / T108-C / T106-C / T17B-C DISPLAYS DAY OR DAY BLOCK PROG 00:0000 PROG PROG ALWAYS OFF

Substitute Quick Reference (SmartFindExpress Substitute Calling System and Web Center)

SOUTH DAKOTA BOARD OF REGENTS. Board Work ******************************************************************************

HP Project and Portfolio Management Center

Using Variables to Write Pattern Rules

CS Programming I: Arrays

Crystal Reports. Overview. Contents. Cross-Tab Capabilities & Limitations in Crystal Reports (CR) 6.x

MBTA Semester Pass Program User Guide

Ada 2005 An introduction for TTK4145

Genesys Info Mart. date-time Section

LIHP Monthly Aggregate Reporting Instructions Manual. Low Income Health Program Evaluation

Table of Contents 1 Basic Configuration Commands 1-1

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays

Installation Manual GENERAL DESCRIPTION...2 WIRING INFORMATION FOR NX-507 AND NX NX-507 TERMINAL DESCRIPTION...3 NX-507 DRAWING...

MONITORING REPORT ON THE WEBSITE OF THE STATISTICAL SERVICE OF CYPRUS DECEMBER The report is issued by the.

Employer Portal Guide. BenefitWallet Employer Portal Guide

SOUTH DAKOTA BOARD OF REGENTS. Board Work ******************************************************************************

CHAPTER 5 FLOW OF CONTROL

Zodiac Link QUICKSTART GUIDE

with Ada.Text_IO; with Ada.Integer_Text_IO; with Ada.IO_Exceptions; procedure Assign11 is

Enumerated Types. CSE 114, Computer Science 1 Stony Brook University

Chapter 6 Reacting to Player Input

Final Project. Analyzing Reddit Data to Determine Popularity

EXAMINATIONS 2012 MID-YEAR NWEN 241 SYSTEMS PROGRAMMING. The examination contains 5 questions. You must answer ALL questions

NetworX Series NX-1710E Single Door Control. Installation and Startup Manual

Student Information Systems (SIS) Updates

SYNOPSIS This pracnique explores an Ada program to apply Luhn s algorithm to verify credit card information.

Your Local Family Bus Company The Bus Garage, Bromyard, HR7 4NT

SOUTH DAKOTA BOARD OF REGENTS PLANNING SESSION AUGUST 8-9, Below is a tentative meeting schedule for the Board meetings in 2013:

A method is a code block that contains a series of statements. Methods. Console.WriteLine(); Console.ReadKey(); Console.ReadKey(); int.

Poinsettias On The Square

Conditional Formatting

Transcription:

16.35 Aerospace Software Engineering Ada 95: subtypes, enumeration types, functions, packages, exception handling September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 1

Subtypes subtype Natural is Integer range 0..Integer Last; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 2

Subtypes subtype Natural is Integer range 0..Integer Last; subtype Positive is Integer range 1..Integer Last; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 2

Subtypes subtype Natural is Integer range 0..Integer Last; subtype Positive is Integer range 1..Integer Last; subtype NonNegativeFloat is Float range 0.0.. Float Last; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 2

Subtypes subtype Natural is Integer range 0..Integer Last; subtype Positive is Integer range 1..Integer Last; subtype NonNegativeFloat is Float range 0.0.. Float Last; subtype SmallInt is Integer range -50..50; subtype CapitalLetter is Character range A.. Z ; X, Y, Z : SmallInt; NextChar : CapitalLetter; Hours_Worked : NonNegFloat; X := 25; Y := 26; Z := X + Y; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 2

Enumeration Types type Class is (Freshman, Sophomore, Junior, Senior); 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 3

Enumeration Types type Class is (Freshman, Sophomore, Junior, Senior); type Traffic_Light_Colours is (Red, Yellow, Green); type Favourite_Colours is (Red, Yellow, Green); type Primary_TV_Colours is (Red, Yellow, Green); 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 3

Enumeration Type Attributes and Operations type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 4

Enumeration Type Attributes and Operations type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); Today : Days; --current day of the week Tomorrow : Days; --day after Today Today := Friday; Tomorrow := Saturday; Days First Days Last Days Pos(Monday) Days Val(0) Days Pred(Wednesday) Days Pred(Today) Days Succ(Tuesday) Days Succ(Today) 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 4

Enumeration Type Attributes and Operations type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); Today : Days; --current day of the week Tomorrow : Days; --day after Today Today := Friday; Tomorrow := Saturday; Days First Days Last Days Pos(Monday) Days Val(0) Days Pred(Wednesday) Days Pred(Today) Days Succ(Tuesday) Days Succ(Today) is Monday is Sunday is 0 is Monday is Tuesday is Thursday is Wednesday is Saturday 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 4

Input/Output Operations type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 5

Input/Output Operations type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); package Day_IO is new Ada.Text_IO.Enumeration_IO(Enum=>Days); 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 5

Input/Output Operations type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); package Day_IO is new Ada.Text_IO.Enumeration_IO(Enum=>Days); Day_IO.Get(Item => Today); Day_IO.Put(Item => Today, Width => 10); 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 5

ADT Packages Different kinds of resources provided by a package Types and subtypes Procedures, functions 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 6

ADT Packages Different kinds of resources provided by a package Types and subtypes Procedures, functions package Ada.Calendar is -- standard Ada package, must be supplied with compilers -- provides useful services for dates and times type Time is private; subtype Year_Number is Integer range 1901.. 2099; subtype Month_Number is Integer range 1.. 12; Subtype Day_Number is Integer range 1.. 31; function Clock return Time; function Year (Date : Time) return Year_Number; function Month (Date : Time) return Month_Number; function Day (Date : Time) return Day_Number; end Ada.Calendar; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 6

SEPTEMBER 30, 2002 Problem specification Display today s date in the form MONTH dd, yyyy WITH Ada.Text_IO; WITH Ada.Integer_Text_IO; WITH Ada.Calendar; PROCEDURE Todays_Date IS TYPE Months IS (January, February, March, April, May, June, July, August, September, October, November, December); PACKAGE Months_IO IS NEW Ada.Text_IO.Enumeration_IO(Enum => Months); RightNow : Ada.Calendar.Time; -- current time ThisYear : Ada.Calendar.Year_Number; -- current year ThisMonth : Ada.Calendar.Month_Number; -- current month ThisDay : Ada.Calendar.Day_Number; -- current day MonthName : Months; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 7

SEPTEMBER 30, 2002 BEGIN -- Todays_Date -- Get the current time value from the computer's clock RightNow := Ada.Calendar.Clock; -- Extract current month, day, and year from the time value ThisMonth := Ada.Calendar.Month(Date => RightNow); ThisDay := Ada.Calendar.Day (Date => RightNow); ThisYear := Ada.Calendar.Year (Date => RightNow); -- Format and display the date MonthName := Months'Val(ThisMonth - 1); Ada.Text_IO.Put (Item => "Today's date is "); Months_IO.Put (Item => MonthName, Set => Ada.Text_IO.Upper_Case); Ada.Text_IO.Put (Item => ' '); Ada.Integer_Text_IO.Put (Item => ThisDay, Width => 1); Ada.Text_IO.Put (Item => ','); Ada.Integer_Text_IO.Put (Item => ThisYear, Width => 5); Ada.Text_IO.New_Line; END Todays_Date; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 8

SEPTEMBER 30, 2002 BEGIN -- Todays_Date -- Get the current time value from the computer's clock RightNow := Ada.Calendar.Clock; -- Extract current month, day, and year from the time value ThisMonth := Ada.Calendar.Month(Date => RightNow); ThisDay := Ada.Calendar.Day (Date => RightNow); ThisYear := Ada.Calendar.Year (Date => RightNow); -- Format and display the date MonthName := Months'Val(ThisMonth - 1); Ada.Text_IO.Put (Item => "Today's date is "); Months_IO.Put (Item => MonthName, Set => Ada.Text_IO.Upper_Case); Ada.Text_IO.Put (Item => ' '); Ada.Integer_Text_IO.Put (Item => ThisDay, Width => 1); Ada.Text_IO.Put (Item => ','); Ada.Integer_Text_IO.Put (Item => ThisYear, Width => 5); Ada.Text_IO.New_Line; END Todays_Date; Sample Run: Today s date is SEPTEMBER 30, 2002 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 8

WITH Ada.Text_IO; WITH Ada.Float_Text_IO; WITH Ada.Numerics.Elementary_Functions; PROCEDURE Square_Roots IS Ada s Math Library SUBTYPE NonNegFloat IS Float RANGE 0.0.. Float'Last; First : NonNegFloat; Second: NonNegFloat; Answer: NonNegFloat; BEGIN -- Square_Roots Ada.Text_IO.Put (Item => "Please enter first number > "); Ada.Float_Text_IO.Get(Item => First); Answer := Ada.Numerics.Elementary_Functions.Sqrt(X => First); Ada.Text_IO.Put (Item => "The first number's square root is "); Ada.Float_Text_IO.Put (Item => Answer, Fore => 1, Aft => 5, Exp => 0); Ada.Text_IO.New_Line; Ada.Text_IO.Put (Item => "Please enter second number > "); Ada.Float_Text_IO.Get(Item => Second); Ada.Text_IO.Put (Item => "The second number's square root is "); Ada.Float_Text_IO.Put (Item => Ada.Numerics.Elementary_Functions.Sqrt (X => Second), Fore => 1, Aft => 5, Exp => 0); Ada.Text_IO.New_Line; Answer := Ada.Numerics.Elementary_Functions.Sqrt(X => First + Second); Ada.Text_IO.Put (Item => "The square root of the sum of the numbers is "); Ada.Float_Text_IO.Put (Item => Answer, Fore => 1, Aft => 5, Exp => 0); Ada.Text_IO.New_Line; END Square_Roots; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 9

Sample Run 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 10

Sample Run Please enter first number > 9 The first number s square root is 3.00000 Please enter second number > 16 The second number s square root is 4.00000 The square root of the sum of the numbers is 5.00000 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 10

Writing Functions function Year (Date: Time) return Year_Number; function Month (Date: Time) return Month_Number; function Day (Date: Time) return Day_Number; function Maximum (Value1, Value2: Integer) return Integer; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 11

Writing Functions function Year (Date: Time) return Year_Number; function Month (Date: Time) return Month_Number; function Day (Date: Time) return Day_Number; function Maximum (Value1, Value2: Integer) return Integer; Larger := Maximum (Value1 => 24, Value2 => -57); 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 11

Writing Functions function Year (Date: Time) return Year_Number; function Month (Date: Time) return Month_Number; function Day (Date: Time) return Day_Number; function Maximum (Value1, Value2: Integer) return Integer; Larger := Maximum (Value1 => 24, Value2 => -57); Grade1 := 24; Grade2 := -57; Larger := Maximum (Value1 => Grade1, Value2 => Grade2); 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 11

Writing Functions function Year (Date: Time) return Year_Number; function Month (Date: Time) return Month_Number; function Day (Date: Time) return Day_Number; function Maximum (Value1, Value2: Integer) return Integer; Larger := Maximum (Value1 => 24, Value2 => -57); Grade1 := 24; Grade2 := -57; Larger := Maximum (Value1 => Grade1, Value2 => Grade2); function Maximum (Value1, Value2: Integer) return Integer is Result: Integer; -- Local variable in function begin if Value1 > Value2 then Result := Value1; else Result := Value2; end if; return Result; end Maximum; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 11

WITH Ada.Text_IO; WITH Ada.Integer_Text_IO; PROCEDURE Max_Two IS FirstValue: Integer; -- input SecondValue: Integer; -- input Larger: Integer; -- output Max_Two -- function specification FUNCTION Maximum (Value1, Value2: Integer) RETURN Integer; -- function body FUNCTION Maximum (Value1, Value2: Integer) RETURN Integer IS Result: Integer; BEGIN IF Value1 > Value2 THEN Result := Value1; ELSE Result := Value2; END IF; RETURN Result; END Maximum; BEGIN Ada.Text_IO.Put (Item => "Please enter first integer value > "); Ada.Integer_Text_IO.Get (Item => FirstValue); Ada.Text_IO.Put (Item => "Please enter second integer value > "); Ada.Integer_Text_IO.Get (Item => SecondValue); Larger := Maximum(Value1=>FirstValue, Value2=>SecondValue); Ada.Text_IO.Put (Item => "The larger number is "); Ada.Integer_Text_IO.Put (Item => Larger, Width => 1); Ada.Text_IO.New_Line; END Max_Two; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 12

Writing a Package: vecmanagement.ads Package specification.ads Package body.adb Package to handle one-dimensional vectors of type Float 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 13

Writing a Package: vecmanagement.ads Package specification.ads Package body.adb Package to handle one-dimensional vectors of type Float package Vecmanagement is subtype Index is Integer range 0..Integer'Last; type Vector is array (Index range <>) of Float; Incompatdims : exception; function "+" (U, V : in Vector ) return Vector; function "-" (U, V : in Vector ) return Vector; function "*" (U, V : in Vector ) return Vector; function "*" (X : in Float; V : in Vector ) return Vector; end Vecmanagement; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 13

Writing a Package: vecmanagement.adb package body Vecmanagement is function "+" (U, V : in Vector )return Vector is Dim : constant Integer := U'Length; W : Vector (1.. Dim); begin if V'Length /= Dim then raise Incompatdims ; end if; for I in 1..Dim loop W(I) := U(I) + V(I); end loop; return W; end "+"; function "-" (U, V : in Vector )return Vector is Dim : constant Integer := U'Length; W : Vector (1.. Dim); begin if V'Length /= Dim then raise Incompatdims ; end if; for I in 1..Dim loop W(I) := U(I) - V(I); end loop; return W; end "-"; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 14

Writing a Package: vecmanagement.adb package body Vecmanagement is function "+" (U, V : in Vector )return Vector is Dim : constant Integer := U'Length; W : Vector (1.. Dim); begin if V'Length /= Dim then raise Incompatdims ; end if; for I in 1..Dim loop W(I) := U(I) + V(I); end loop; return W; end "+"; function "-" (U, V : in Vector )return Vector is Dim : constant Integer := U'Length; W : Vector (1.. Dim); begin if V'Length /= Dim then raise Incompatdims ; end if; for I in 1..Dim loop W(I) := U(I) - V(I); end loop; return W; end "-"; function "*" (U, V: in Vector)return Vector is Dim : constant Integer := U'Length; W : Vector (1.. Dim); begin if V'Length /= Dim then raise Incompatdims ; end if; for I in 1..Dim loop W(I) := U(I) * V(I); end loop; return W; end "*"; function "*" (X: in Float; V: in Vector)return Vector is Dim : constant Integer := V'Length; W : Vector (1.. Dim); begin for I in 1..Dim loop W(I) := X * V(I); end loop; return W; end "*"; end Vecmanagement; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 14

Writing a Package: tryvecs.adb with Vecmanagement; use Vecmanagement; with Ada.Float_Text_Io; with Text_Io; use Text_Io; procedure Tryvecs is A : Vector (1.. 3); B : Vector (1.. 3); C : Vector (1.. 4); begin for I in 1..3 loop A(I) := Float(I); end loop; for I in 1..4 loop C(I) := 1.0; end loop; B := A + A; for I in 1..3 loop Ada.Float_Text_Io.Put(B(I)); New_Line; end loop; C := A + C; Put("Tried that"); New_Line; exception when Incompatdims => Put("Incompatible sizes"); New_Line; end Tryvecs; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 15

Writing a Package: tryvecs.adb with Vecmanagement; use Vecmanagement; with Ada.Float_Text_Io; with Text_Io; use Text_Io; procedure Tryvecs is A : Vector (1.. 3); B : Vector (1.. 3); C : Vector (1.. 4); begin for I in 1..3 loop A(I) := Float(I); end loop; for I in 1..4 loop C(I) := 1.0; end loop; B := A + A; for I in 1..3 loop Ada.Float_Text_Io.Put(B(I)); New_Line; end loop; C := A + C; Put("Tried that"); New_Line; exception when Incompatdims => Put("Incompatible sizes"); New_Line; end Tryvecs; The output is: 2.00000E+00 4.00000E+00 6.00000E+00 Incompatible sizes 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 15

Exception Handling loop Prompt user for input value Get input from user exit loop if and only if no exception raised on input If exception raised, notify user end loop; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 16

Exception Handling loop Prompt user for input value Get input from user exit loop if and only if no exception raised on input If exception raised, notify user end loop; when exception_name => sequence of statements 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 16

Exception Handling loop Prompt user for input value Get input from user exit loop if and only if no exception raised on input If exception raised, notify user end loop; when exception_name => sequence of statements when Constraint_Error => Ada.Text_IO.Put (Item => Input number is out of range ); Ada.Text_IO.New_Line; Ada.Text_IO.Put (Item => Try entering it again ); Ada.Text_IO.New_Line; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 16

Exception Handling loop begin Prompt user for input value Get input from user exit; -- valid data exception -- invalid data Determine which exception was raised and notify the user end; end loop; Constraint_Error Ada.Text_IO.Data_Error Ada.Numerics.Argument_Error begin normal sequence of statements exception when exception_name 1 => sequence of statements when exception_name n => sequence of statements end; 16.35 September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 17