First of all, a comment on the education system--
whatever class you're in, your teacher is not doing his/her job.
May I ask whether this is a high school class? The problem
with our education system today is the dysfunctional recurrence
of pushing our students to the limit with tons of AP classes
while sacrificing the need to give them time to learn things
the right way. The false importance of GPA and college applications
has gotten to the point of laughable absurdity. So,
xarqi-ga, if your current education system is as I described,
it's time to re-examine personal values and make a change to the
system.
Now for the answer--I did this by mere inspection without a compiler
(FYI, the Turbo Pascal compiler for Windows 1.5 is not Y2K compliant
and has been discontinued by Borland--apparently your education
institute isn't aware of this mere fact either):
program atmaccounts (input, output);
uses wincrt;
const
five=5;
seven=7;
ten=10;
twelve=12;
type
AccRec= record
accountname, accountnumber: string[20];
newbalance, amount: real;
accountype, select: char;
end;
list = Array [1..20] of AccRec;
var
select: char;
customers: list;
listend: integer;
continue: char;
procedure welcome;
begin
clrscr;
writeln('*****************************************');
writeln('*Welcome To Uxbridge College Atm Machine*');
writeln('*****************************************');
write('press enter to continue');
readln(continue);
end;
procedure endmessage;;
begin
clrscr;
writeln('*********************************************');
writeln('*Thank You from Uxbridge College Atm Machine*');
writeln('*********************************************');
end;
(*****************************************************************)
procedure Menu( var select : char);
begin
clrscr;
writeln('Customers Records');
writeln('=================');
writeln;
writeln(' 1......Input customers details');
writeln(' 2......Display accounts details');
writeln(' 9......Exit');
writeln('Enter your selection');
readln(select);
end;
(*****************************************************************)
procedure input (var customers:list; var listend:integer);
var accountname, accountnumber: string[20]; var
accountype: char; var amount: real;
begin
write('Enter account holders name =>');
readln(accountname);
writeln;
write('Enter accountnumber =>');
readln(accountnumber);
writeln;
write('Enter current balance =>');
readln(amount);
writeln;
repeat
write('Enter account type as S or C =>');
readln(accountype);
writeln;
until (accountype = 'C') or (accountype = 'S') or
(accountype = 'c') or (accountype = 's');
listend:= listend + 1;
customers[listend].accountname:= accountname;
customers[listend].accountnumber:= accountnumber;
customers[listend].amount:= amount;
customers[listend].accountype:= accountype;
end;
(*****************************************************************************)
procedure calculation (var customers:list; var listend:integer);
var i:integer; var accountype:char;
begin
for i:= 1 to listend do
begin
with customers [i] do
begin
case
accountype of
'c' : if amount <100 then
newbalance:=amount+(amount*five/100)
else
newbalance:=amount+(amount*seven/100);
's' : if amount <5000 then
newbalance:=amount+(amount*ten/100);
else
newbalance:=amount+(amount*twelve/100);
end;
end;
end;
end;
(********************************************************************)
procedure display( var customers:list; var listend:integer);
var i: integer;
begin
if listend >0 then
begin
writeln('Account name':16, 'Acct No. ':11, 'A/C Type':10,
'old Balance ':20, 'New balance':20);
writeln('=============':16, '========':11, '=========':10,
'============':20, '===========':20);
for i:=1 To listend Do
begin
with Customers[i] Do
begin
writeln(Accountname:16,Accountnumber:11,AccounType:10,Amount:20:2,newbalance:20:2);
end;
end;
end
else
begin
writeln(' No Accounts in the system');
end;
end;
(****************************************************************)
begin
listend:=0;
welcome;
repeat
Menu(select);
Case select of
'1' : Input(customers, listend);
'2' : Display(customers, listend);
end;
Until select = '9';
endmessage;
end. |
Clarification of Answer by
studboy-ga
on
03 Jun 2003 17:42 PDT
program atmaccounts (input, output);
uses wincrt;
const
five=5;
seven=7;
ten=10;
twelve=12;
type
AccRec= record
accountname, accountnumber: string[20];
newbalance, amount: real;
accountype, select: char;
end;
list = Array [1..20] of AccRec;
var
select: char;
customers: list;
listend: integer;
continue: char;
procedure welcome;
begin
clrscr;
writeln('*****************************************');
writeln('*Welcome To Uxbridge College Atm Machine*');
writeln('*****************************************');
write('press enter to continue');
readln(continue);
end;
procedure endmessage;
begin
clrscr;
writeln('*********************************************');
writeln('*Thank You from Uxbridge College Atm Machine*');
writeln('*********************************************');
end;
(*****************************************************************)
procedure Menu( var select : char);
begin
clrscr;
writeln('Customers Records');
writeln('=================');
writeln;
writeln(' 1......Input customers details');
writeln(' 2......Display accounts details');
writeln(' 9......Exit');
writeln('Enter your selection');
readln(select);
end;
(*****************************************************************)
procedure input (var customers:list; var listend:integer);
var accountname, accountnumber: string[20]; var
accountype: char; var amount: real;
begin
write('Enter account holders name =>');
readln(accountname);
writeln;
write('Enter accountnumber =>');
readln(accountnumber);
writeln;
write('Enter current balance =>');
readln(amount);
writeln;
repeat
write('Enter account type as S or C =>');
readln(accountype);
writeln;
until (accountype = 'C') or (accountype = 'S') or
(accountype = 'c') or (accountype = 's');
listend:= listend + 1;
customers[listend].accountname:= accountname;
customers[listend].accountnumber:= accountnumber;
customers[listend].amount:= amount;
customers[listend].accountype:= accountype;
end;
(*****************************************************************************)
procedure calculation (var customers:list; var listend:integer);
var i:integer; var accountype:char;
begin
for i:= 1 to listend do
begin
with customers [i] do
begin
case
accountype of
'c' : if amount <100 then
newbalance:=amount+(amount*five/100)
else
newbalance:=amount+(amount*seven/100);
's' : if amount <5000 then
newbalance:=amount+(amount*ten/100);
else
newbalance:=amount+(amount*twelve/100);
end;
end;
end;
end;
(********************************************************************)
procedure display( var customers:list; var listend:integer);
var i: integer;
begin
if listend >0 then
begin
writeln('Account name':16, 'Acct No. ':11, 'A/C Type':10,
'old Balance ':20, 'New balance':20);
writeln('=============':16, '========':11, '=========':10,
'============':20, '===========':20);
for i:=1 To listend Do
begin
with Customers[i] Do
begin
writeln(Accountname:16,Accountnumber:11,AccounType:10,Amount:20:2,newbalance:20:2);
end;
end;
end
else
begin
writeln(' No Accounts in the system');
end;
end;
(****************************************************************)
begin
listend:=0;
welcome;
repeat
Menu(select);
Case select of
'1' : Input(customers, listend);
'2' : Display(customers, listend);
end;
Until select = '9';
endmessage;
end.
|