forked from christianhujer/expensereport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddeff1a
commit a1f72b8
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.o | ||
ExpenseReport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
PROGRAM ExpenseReport; | ||
|
||
USES sysutils; | ||
|
||
TYPE | ||
ExpenseType = (Dinner, Breakfast, CarRental); | ||
Expense = RECORD | ||
type_: ExpenseType; | ||
amount: integer; | ||
END; | ||
|
||
PROCEDURE printReport(expenses: ARRAY OF Expense); | ||
VAR total: integer = 0; | ||
VAR mealExpenses: integer = 0; | ||
VAR exp: Expense; | ||
VAR expenseName: string; | ||
VAR mealOverExpensesMarker: string; | ||
BEGIN | ||
writeln('Expenses: ', FormatDateTime('YYYY-MM-DD hh:mm:ss', Now)); | ||
FOR exp IN expenses DO | ||
BEGIN | ||
IF (exp.type_ = Dinner) OR (exp.type_ = Breakfast) THEN mealExpenses := mealExpenses + exp.amount; | ||
CASE (exp.type_) of | ||
Dinner: expenseName := 'Dinner'; | ||
Breakfast: expenseName := 'Breakfast'; | ||
CarRental: expenseName := 'Car Rental'; | ||
END; | ||
IF (exp.type_ = Dinner) AND (exp.amount > 5000) OR (exp.type_ = Breakfast) AND (exp.amount > 1000) THEN mealOverExpensesMarker := 'X' ELSE mealOverExpensesMarker := ' '; | ||
writeln(expenseName, #9, exp.amount, #9, mealOverExpensesMarker); | ||
total := total + exp.amount; | ||
END; | ||
writeln('Meal expenses: ', mealExpenses); | ||
writeln('Total expenses: ', total); | ||
END; | ||
|
||
|
||
VAR expenses: ARRAY OF Expense; | ||
BEGIN | ||
writeln('Hello, world!'); | ||
END. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.PHONY: all | ||
all: ExpenseReport | ||
./ExpenseReport | ||
|
||
.PHONY: clean | ||
clean:: | ||
$(RM) ExpenseReport *.[adios] | ||
|
||
%: %.pas | ||
fpc $^ |