0

Heyyy everyone =). Im a freshman in Highschool taking a computer programming class.
I was just wondering if you guys could look over my code and see if there is anything
that I could have done more efficiently (i.e. using less ram, less code).
The objective of this program is to read data from a .DAT file and display it in a table.
Here is my output as shown in Console.
[IMG]http://i1024.photobucket.com/albums/y303/XM-SeriesX/output.png?t=1298593419[/IMG]
Thanks!

program check2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const

tab = #9;

(****************************************)


procedure flowrTable;

begin

  writeln ('                                    IDD');
  writeln ('                                    IDD');
  writeln ('                                    IDD');
  writeln ('                                    IDD');
  writeln ('                                    IDD');
  writeln ('                                   I8DDZZI.');
  writeln ('                             8DDDDDDDDDDDDDDDDD.');
  writeln ('                            DDDDDDDDDDDDDDDDDDDD~');
  writeln ('                           DDDDDZ   IDD     =DDD~');
  writeln ('                          DDDDD     IDD         ~');
  writeln ('                          DDDD~     IDD');
  writeln ('                         DDDDI     IDD');
  writeln ('                          DDDDD     IDD');
  writeln ('                          ~DDDDDD+  IDD');
  writeln ('                            DDDDDDDDDDDDZ');
  writeln ('                             .DDDDDDDDDDDDDDDD');
  writeln ('                                    ZDDDDDDDDDDD');
  writeln ('                                    IDD    DDDDDD');
  writeln ('                                    IDD     ~DDDDD');
  writeln ('                                    IDD      DDDDD');
  writeln ('                                    IDD      DDDDD');
  writeln ('                         ~D+        IDD     IDDDD');
  writeln ('                         ~DDDD8     IDD    DDDDD');
  writeln ('                         ~DDDDDDDDDDDDDDDDDDDDD');
  writeln ('                           ODDDDDDDDDDDDDDDDI');
  writeln ('                                  ~~7DD');
  writeln ('                                    IDD');
  writeln ('                                    IDD');
  writeln ('                                   IDD');
  writeln ('                                    IDD');
  writeln ('                                    IDD');
  writeln;
  writeln;
  writeln ('                        <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ');
  writeln ('                          Jordans Bank of Awesomeness   ');
  writeln ('                        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ');
  writeln;
  writeln;
  writeln('           Date         Transaction            Amount         Balance');
  writeln('           ----------------------------------------------------------');
  writeln;




end;


(****************************************)

procedure readLines (var dataFile : text);
var

  date : string[5];
  beginBalance : real;
  amount : real;
  transType : integer;
  transWords : string;
  balance : real;

begin



  readln( dataFile, beginBalance );
  writeln(tab, '                Beginning Balance                    $',  beginBalance:0:2);
  balance := 2035.47;

  while not eof (dataFile) do
    begin
      readln (datafile, date, transType, amount);

      Case transType Of
        -1: transWords := 'Deposit';
        -2: transWords := 'Withdrawal';
        -3: transWords := 'Bank Charge';
          Else
            transWords := 'Check # ';
            transWords := transWords + formatfloat('####', transType);
          End;

      Case transtype of
      -1: balance := balance + amount;
      -2: balance := balance - amount;
      -3: balance := balance - amount;
        else
          balance := balance - amount;
      end;

      if transWords = 'Deposit' then
        begin
          writeln ( '            ', date,'    ', tab, transWords, '        ',  '         ', '$', amount:0:2, tab, '     $', balance:0:2);
        end

          else

      writeln ( '            ', date,'    ', tab, transWords, '      ',  tab, '$', amount:0:2, tab, '     $', balance:0:2);
    end;





end;







(****************************************)

var
  dataFile : text;



begin

  Assign( dataFile, 'CHECK2.DAT');
  Reset ( dataFile );
  flowrTable;
  readLines ( dataFile);
  close( dataFile );

  readln;


end.

Edited by ClanTag: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pritaeas
0

The only thing I can think of is that you can use Format() instead of FormatFloat() if you want to align your 'Amount' values correctly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.