(Note the change in due date - We will need to adjust a few other things as well. We'll straighten all these out after Spring Break.)
In this program you will exercise some of the string handling routines of Pascal. You will be extending the logic and processing of Program 3. Your program will receive input from a text file called LAWYER.DAT (available on or before April 14th). Each non-blank line of this file will be the work record of a single lawyer for a single day working at Biddle, Riddle and Twit, S.C and will be in the following format: the lawyer's name will appear in columns 1-15, the date will appear in columns 16-25 in the format YYYY-MM-DD and then following the date, separated by one or more spaces, will be the work record for the lawyer on the given day in the format: job code, start time in military hh:mm format and ending time in military hh:mm format. For example:
Smith John 2000-10-03 4 08:15 11:45 2 12:35 14:45 3 15:00 17:40You may assume that each line occupies no more than 255 characters and that the last character in each line is a single space. Your code must take into account that each line will contain a variable number of job code and start/stop times. The military time format will utilize an embedded colon (:) to separate hours from minutes. The file lawyer.DAT contains multiple lines belonging to a single lawyer working at Biddle, Riddle and Twit, S.C; your program must be able to process this file regardless of the number of lines it contains; however, each non-blank line of the file will pertain to only one day's work by this lawyer in the shop. As in Program 3, assume that Biddle, Riddle and Twit has had their fee plan in place for many years. The hourly fees rates for each kind of service vary with the difficulty and/or skill level required to perform that service. The services and their hourly fees rates are (these are the actual rates of fees charged to the client for each service):
Service Code Service Description Hourly Rate
0 Personal Time 0.00
1 Wills 50.00
2 Divorce 75.00
3 Bankruptcy 100.00
4 Trust Mgt. 60.00
5 Civil Suit 150.00
As in program 3, your program will note in the output whenever an
illegal job code is encountered; however, the lawyer will be given
no credit for the hours worked in such a case (nor will there be any
fee accrued, of course).Also as before, lawyers charge back to the firm daily time-and-a-half for overtime for all work over 8 hours based on their average hourly rate for the day. For example, if John Smith worked 9 hours on a given day, charging $540.00 for all 9 hours worked (without regard to overtime), his average hourly rate would be $60.00 ($540.00 / 9), and so he would be charge back to the firm one hour of overtime fees, or an extra charge of $30.00 for the day.
To give an example of how your output in this program is to appear, consider the following possible input file
{ Input test file for Program 6, Spring, 2001
Smith, John 2000-10-21 3 08:00 11:15 2 11:20 12:40 0 12:45 13:50 1 14:00 16:00 5 16:10 17:30
John Smith2001-03-02 2 08:10 09:45 1 10:00 12:30 0 12:30 13:00 7 13:00 13:30 4 13:35 17:55
JOHN SMITH 2001-01-23 4 07:30 13:45 0 13:45 14:00 3 14:00 16:00
Smith, J. 2000-11-30 4 11:00 21:00
The output (sent to the output file PROG6.OUT) is to look like this:
Biddle, Riddle and Twit, S.C
=============================================================
Lawyer Start End Job Job Job
Name Time Time Hours Description Fee
=============================================================
J. SMITH 08:00 11:15 3.25 Bankruptcy 325.00
J. SMITH 11:20 12:40 1.33 Divorce 100.00
J. SMITH 12:45 13:50 1.08 Personal time 0.00
J. SMITH 14:00 16:00 2.00 Wills 100.00
J. SMITH 16:10 17:30 1.33 Civil Suit 200.00
=============================================================
SUBTOTALS: 7.92 $725.00
=============================================================
OVERTIME BONUS: 0.00 hrs @ 91.58 / hr $0.00
=============================================================
TOTAL FEE: October 21, 2000 $725.00
=============================================================
J. SMITH 08:10 09:45 1.58 Divorce 118.75
J. SMITH 10:00 12:30 2.50 Wills 125.00
J. SMITH 12:30 13:00 0.50 Personal time 0.00
J. SMITH 13:00 13:30 0.50 ** Job code not found **
J. SMITH 13:35 17:55 4.33 Trust Mgt. 260.00
=============================================================
SUBTOTALS: 8.42 $503.75
=============================================================
OVERTIME BONUS: 0.42 hrs @ 59.85 / hr $12.57
=============================================================
TOTAL FEE: March 2, 2001 $516.32
=============================================================
J. SMITH 07:30 13:45 6.25 Trust Mgt. 375.00
J. SMITH 13:45 14:00 0.25 Personal time 0.00
J. SMITH 14:00 16:00 2.00 Bankruptcy 200.00
=============================================================
SUBTOTALS: 8.25 $575.00
=============================================================
OVERTIME BONUS: 0.25 hrs @ 69.70 / hr $8.71
=============================================================
TOTAL FEE: January 23, 2001 $583.71
=============================================================
J. SMITH 11:00 21:00 10.00 Trust Mgt. 600.00
=============================================================
SUBTOTALS: 10.00 $600.00
=============================================================
OVERTIME BONUS: 2.00 hrs @ 60.00 / hr $60.00
=============================================================
TOTAL FEE: November 30, 2000 $660.00
=============================================================
=============================================================
GRAND TOTALS
Total hours worked: 34.58
Total overtime hours worked: 2.67
Total regular fee earned: $2,403.75
Total overtime bonus earned: $81.28
Total fee earned: $2,485.03
=============================================================
Program #6, Spring 2001
Programmed by <??>, Section <??>
Due: April 10 2001Value = 100 pts
=============================================================
Features of this program in common with Program 3:
Unique features of this program:
Last name, First Name Ex: Smith, John First Name Last Name Ex: John Smith or JOHN SMITH or JOHN smith Last name, First initial. Ex: Smith, J. Your output is to show the lawyer name in a consistent format:
First Initial. Last Name Ex: J. SMITH
(in all caps)
YOU ARE REQUIRED TO USE THE FOLLOWING PROGRAMMING ELEMENTS IN YOUR PROGRAM 6 CODE:
REFERENCE
A function which will accept a real valued parameter Amount and return the value in Amount properly rounded to the nearest hundredth:
Function Round_to_hundreths(Amount: Double): Double;
Const
Move_decimal_pt = 100;
Small_round_up = 0.00500001;
Var
New_amount: Double;
Round_up: LongInt;
Begin
New_amount := Amount * Move_decimal_pt;
Round_up := ROUND(New_amount + Small_round_up);
Round_to_hundreths := Round_up / Move_decimal_pt;
End;
The next function uses the following TYPE and VAR definitions:
Type Numeric_string: String[25]; Var X: Longint; Format_X: Numeric_string;The following function named CONVERT_TO_STRING is designed to be passed the value of a long integer X and will return a string of type Numeric_String using the calling statement:
Format_X := CONVERT_TO_STRING(X);The value returned by this function will be a string containing the digits in X separated into clusters of three digits separated by commas.
Function Convert_to_string(X: Longint): Numeric_String;
Const
Comma = ',';
Var
Count, Long, Location: Integer;
Z: Numeric_string;
Begin
Str(X, Z);
Long := Length(Z);
Count := 0;
For Location := Long downto 2 Do
Begin
Count := SUCC(Count);
If Count MOD 3 = 0
Then Insert(Comma, Z, Location)
End;
Convert_to_string := Z
End;
So, for example, if X = 1234567890, then the statement
Writeln(Convert_to_string(X));
will print 1,234,567,890 on the user's screen.
![]() |
Return to CS-171 Home Page |
![]() |
Return to UW-W Home Page |
|