{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

pset4_sol_

# pset4_sol_ - C8-1 Algorithm 1 Use a subtype to represent...

This preview shows pages 1–4. Sign up to view the full content.

C8-1 Algorithm 1. Use a subtype to represent the numbers for months 2. Use an enumeration to represent the named months 3. Use an enumeration to represent the roman months 4. Get the inputs from the user 5. Convert the month into roman and named formats using a. New_Type_Package’Val(Month_Type’Pos(Month) –1); 6. Display the months in all three formats to the user. Note: The enumerations range from 0 to (number_of_elements_in_Enumeration –1). Code Listing GNAT 3.13 p ( 20000509 ) Copyright 1992 - 2000 Free Software Foundation, Inc. Compiling: c:/docume~ 2 /jk/desktop/ 16070 /codeso~ 1 /translate_dates.adb (source file time stamp: 2003 - 09 - 24 01 : 35 : 00 ) 1 . -------------------------------------------------------------------- 2 . -- Program to accept different date formats 3 . -- Programmer : Jayakanth Srinivasan 4 . -- Date Last Modified : 09-23-2003 5 . -------------------------------------------------------------------- 6 . 7 . with Ada.Text_Io; 8 . with Ada.Integer_Text_Io; 9 . 10 . procedure Translate_Dates is 11 . --use a subtype to limit the date to be between 1 and 31. 12 . subtype Date_Type is Integer range 1 .. 31 ; 13 . -- use a subtype to limit the month to be between 1 and 12 14 . subtype Month_Type is Integer range 1 .. 12 ; 15 . 16 . -- define an enumeration type for roman months 17 . type Roman_Month_Type is 18 . (I, 19 . Ii, 20 . Iii, 21 . Iv, 22 . V, 23 . Vi, 24 . Vii, 25 . Viii, 26 . Ix, 27 . X, 28 . Xi, 29 . Xii); 30 . 31 . -- define an enumeration type for names of months 32 . type Named_Month_Type is

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
91 . Ada.Text_Io.Put( " " ); 92 . Ada.Integer_Text_Io.Put(Year); 93 . Ada.Text_Io.New_Line; 94 . 95 . -- display the date in roman format 96 . Ada.Text_Io.Put( " iii. " ); 97 . Ada.Integer_Text_Io.Put(Date); 98 . Ada.Text_Io.Put( "." ); 99 . Roman_Month_Io.Put(Roman_Month); 100 . Ada.Text_Io.Put( "." ); 101 . Ada.Integer_Text_Io.Put(Year); 102 . Ada.Text_Io.New_Line; 103 .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 22

pset4_sol_ - C8-1 Algorithm 1 Use a subtype to represent...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online