Banking System

Ok, so I'm new to Pascal and I have a program due in the morning _..I have been trying all day and still can't do it. Bassically, I have to make a program that can search through a pre-made file (RECORD obviously)
and display the info, plus make changes to it.



Comments

  • : Ok, so I'm new to Pascal and I have a program due in the morning _..I have been trying all day and still can't do it. Bassically, I have to make a program that can search through a pre-made file (RECORD obviously)
    : and display the info, plus make changes to it.
    :
    :
    :
    :
    The program is supposed to be a simple banking system, displays name, balance and such and then make a change to the payment. Now, my code is completely screwed up. I don't need anyone to make the program from me I just need help overcoming this small obstacle. When it asks me to type in a name, I press enter (or enter any name) and it displays the first person on the record and no others....whoevers name I type. This is very annoying and I have no idea what is wrong. It would be so appreciated. Here's my code,it shouldn't be that hard for an expert to do it.

    TYPE
    st_rec = RECORD
    name : STRING[30];
    unpaid_balance, total : real;
    END;
    VAR
    customer : st_rec;
    classf : FILE OF st_rec;
    loop : CHAR;
    x : integer;

    Procedure Welcome;
    Begin
    Writeln('Welcome, hit enter to begin.');
    Readln;
    end;

    Procedure Enter_info;
    Begin
    ASSIGN(classf,'C:Documents and SettingsJosephC:Documents and SettingsJosephDesktopATMdetails.dat');{ Give file a (DOS) name on disk}
    RESET(classf);
    Begin
    read(classf,customer);
    Begin
    writeln;
    writeln(Customer.name);
    writeln(Customer.unpaid_balance);
    writeln(Customer.total);
    readln;
    end;
    close(classf);
    end;

    Begin

    Welcome;
    Enter_info;

    end.

  • : : Ok, so I'm new to Pascal and I have a program due in the morning _..I have been trying all day and still can't do it. Bassically, I have to make a program that can search through a pre-made file (RECORD obviously)
    : : and display the info, plus make changes to it.
    : :
    : :
    : :
    : :
    : The program is supposed to be a simple banking system, displays name, balance and such and then make a change to the payment. Now, my code is completely screwed up. I don't need anyone to make the program from me I just need help overcoming this small obstacle. When it asks me to type in a name, I press enter (or enter any name) and it displays the first person on the record and no others....whoevers name I type. This is very annoying and I have no idea what is wrong. It would be so appreciated. Here's my code,it shouldn't be that hard for an expert to do it.
    :
    : TYPE
    : st_rec = RECORD
    : name : STRING[30];
    : unpaid_balance, total : real;
    : END;
    : VAR
    : customer : st_rec;
    : classf : FILE OF st_rec;
    : loop : CHAR;
    : x : integer;
    :
    : Procedure Welcome;
    : Begin
    : Writeln('Welcome, hit enter to begin.');
    : Readln;
    : end;
    :
    : Procedure Enter_info;
    : Begin[red]1[/red]
    : ASSIGN(classf,'C:Documents and SettingsJosephC:Documents and SettingsJosephDesktopATMdetails.dat');{ Give file a (DOS) name on disk}
    : RESET(classf);
    : Begin[red]2[/red]
    : read(classf,customer);
    : Begin[red]3[/red]
    : writeln;
    : writeln(Customer.name);
    : writeln(Customer.unpaid_balance);
    : writeln(Customer.total);
    : readln;
    : end;[red]3[/red]
    : close(classf);
    : end;[red]2[/red]
    :
    : Begin
    :
    : Welcome;
    : Enter_info;
    :
    : end.
    :
    :
    First of all, you never ask the user the name to search for.
    Secondly, the begin-end pairings in the procedure are wrong. I've indicated which end matches which begin in red numbers above.
    Finally, you read only 1 record and then close the file. Here is part of the code to scan a file for a certain record:
    [code]
    CustomerFound := false; { assume customer is not found }
    while not eof(classf) do
    begin
    read(classf, customer);
    if [red]{check for found condition}[/red] then
    begin
    CustomerFound := true; { Customer is found }
    Break; { stop reading the file }
    end;
    end;
    [/code]
    The red part needs to be designed by you, as is the variable declaration, and the output.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories