FloridaTech - College of Engineering
CSE1001 - LABORATORY
Author: Jamal Faik
Lab Assignment 8: Types
In this lab, you'll have to implement a type TIME and its associated
routines.
You'll also implement,as a take_home problem, a type
VERY_LONG_INTEGER.
- Type TIME is...;
- Function get_time (S : STRING) return TIME;
get_time takes as argument a string S representing a time and
return a value of type TIME. S is in the
format hours:minutes:seconds (Example: 5:12:30). If minutes or seconds
exceeds 60, then appropriate adjustment should be made. For example calls
to get_time(15:59:130) and get_time(16:01:10)
should return the same value of type TIME.
- Function put_time (T : inTIME);
A call to put_time(T) outputs T in the format hours:minutes:seconds.
- Function "+" (T1, T2 : inTIME) return TIME;
Add T1 and T2 to produce a value of type TIME.
- Function "-" (T1, T2 : inTIME) return TIME;
Substract T2 and T1 to produce a value of type TIME.
Take-Home Problem : Very_Long Integers
In this problem, you are to implement a type VERY_LONG_INTEGER(VLI) as its
associated routines. A VLI is a 1000-digit number, the leftmost position
serve for sign (0 if the number positive and 1 if negative). You will
use strings to implement the type VLI. You also need to write the
following subprograms :
- function "+" (n.m : VLI) return VLI;
- function "-" (n : VLI) return VLI;
- function "-" (n.m : VLI) return VLI;
- function "*" (n.m : VLI) return VLI;
- procedure get (n : out VLI);
- procedure put (n : in VLI);