Google Answers Logo
View Question
 
Q: pascal programming ( Answered 4 out of 5 stars,   4 Comments )
Question  
Subject: pascal programming
Category: Computers > Programming
Asked by: lifeafterdeath-ga
List Price: $100.00
Posted: 02 Jun 2003 07:57 PDT
Expires: 02 Jul 2003 07:57 PDT
Question ID: 211950
[note: please compile and run this program, i wasn't able to compile
it cause of the problem i had in the last section. just solve the last
problem at the end of the program and send it back thank you.]

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;
   cutomers: 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 input (var accountname, accountnumber: string; var
accountype: char; var amount:real);


  begin
       write('Enter account holders name      =>');
       readln(accountname);
       writeln;
       write('Enter account type              =>');
       readln(accountype);
       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');
                   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;
repeat
  Menu('select');
  Case select of

  '1' : Input(coustomers, listend);
  '2' : Display(customers, listend);
  end;
Until select = '9';
endmessage;

end.

Request for Question Clarification by ragingacademic-ga on 02 Jun 2003 09:46 PDT
lifeafterdeath -

Thanks for your question.
Could you please provide the requirements for this program?

Would help solve...

thanks,
ragingacademic

Request for Question Clarification by jeanluis-ga on 02 Jun 2003 17:28 PDT
Could you also provide platform (windows, linux, etc...) and let us
know which compiler... Just to make sure it 100% works for you.
Thanks,
--jld

Clarification of Question by lifeafterdeath-ga on 03 Jun 2003 04:29 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;
   cutomers: list;
   listend: integer;
   continue: char;
   customers1: list;


   


 procedure welcome;

   begin
        clrscr;
        writeln('*****************************************');
        writeln('*Welcome To Uxbridge College Atm Machine*');
        writeln('*****************************************');
        write('press enter to continue');
        readln(continue);
         

   end;

(*****************************************************************)
 procedure Menu( var select : char);

   begin
        clrscr;
        writeln('Customers Records');
        writeln('=================');
        writeln;
        writeln('  1......Input customerss details');
        writeln('  2......Display accounts details');
        writeln('  9......Exit');
        writeln('Enter your selection');
        readln(select);
        end;
(*****************************************************************)

procedure input (var accountname, accountnumber: string; var
accountype: char; var amount:real);


  begin
       write('Enter account holders name      =>');
       readln(accountname);
       writeln;
       write('Enter account type              =>');
       readln(accountype);
       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');
                   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;
repeat
  Menu(select);
  Case select of

  '1' : Input(customers, listend);
  '2' : Display(customers, listend);
  end;
Until select = '9';
endmessage;

end.

Clarification of Question by lifeafterdeath-ga on 03 Jun 2003 04:33 PDT
IF YOU SEE THE DIFFERENCE NOW I HAVE ADDED A NEW PROCEDURE WHICH IS
'PROCEDURE MENU' BUT STILL THERE IS A PROBLEM AT THE LAST SECTION OF
THE PROGRAM.
YOU NEED A [TURBO PASCAL WINDOWS 2000 COMPILER TW 1.5] AND WHO EVER
DOES COULD YOU ADD A FRIENDLY EXIT SCREEN EXAMPLE SAYING 'THANK YOU'
Answer  
Subject: Re: pascal programming
Answered By: studboy-ga on 03 Jun 2003 17:15 PDT
Rated:4 out of 5 stars
 
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:15 PDT
And I'm 100% certain it will compile.

Clarification of Answer by studboy-ga on 03 Jun 2003 17:17 PDT
Oops.  An apology to xarqi-ga, I meant to address lifeafterdeath-ga :)

Clarification of Answer by studboy-ga on 03 Jun 2003 17:20 PDT
Please change

procedure endmessage;;

to 

procedure endmessage;

sorry

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.

Request for Answer Clarification by lifeafterdeath-ga on 04 Jun 2003 08:04 PDT
studboy-ga You are a star!!! but what i need you to do is to make the
program display the customers input when i select Number '2' on the
menu it is meant to display a report of all the inputs but instead
nothing happens. i want the program to display a report:
Account name 
account number
account type
current balance
interest rate [ in which the was used to calculate the most recent
customer
newbalance.

 
studboy:
[iam a first year college student. ] just tryin to survive

Clarification of Answer by studboy-ga on 04 Jun 2003 09:10 PDT
Hi lifeafterdeath-ga

Thanks!  I believe it does display the acct record--
you have to enter a record via menu item 1 first, then when you
go to 2 it will display it.

Clarification of Answer by studboy-ga on 04 Jun 2003 09:55 PDT
Please check the display procedure--currently it does not have
interest rate--I don't think your instructor rate, does he?  If he
does he should give it to you in the display procedure.  Please double
check with him.
Also, new balance is not updated in display either--please double
check with the instructor to see if what he gave you is what he wants.
 If he wants something *other than* what he gave you--for example, if
he wants new balance updated, you will need to call calculation inside
display.

Again, I think you have a bad instructor (he's unclear and clueless). 
Report him to the dean so he doesn't get to teach this class ever
again.
lifeafterdeath-ga rated this answer:4 out of 5 stars and gave an additional tip of: $20.00
well done studboy iam pleased thanks for saving me 22 brain cells hahahahaha.

thanks life after death

Comments  
Subject: Re: pascal programming
From: xarqi-ga on 03 Jun 2003 01:34 PDT
 
Can't compile it - don't have either a compiler or the runtime library
you are using.  I shall proceed undaunted!

A couple of things look weird to me:
First is the misspelling in the line:
'1' : Input(coustomers, listend); 
----------^

Second is the use of the procedure "menu".
Since it is not defined in the program I assume it to be in the
run-time library.
From the structure, it looks as if you are expecting your local
variable -select- to receive some value as a result of the execution
of this procedure.  However, you have passed it the text string
'select' as a parameter.  Could it be that menu is a function that
returns a value, and its parameter is a prompt string?  If so, you
might need:
select := menu('select');
This looks a dubious construct to me since the passing of static
strings to procedures is quite nasty in PASCAL, which does not have a
native string type.

Alternatively, perhaps its parameter should be a variable to receive
the value:
menu(select);
This would make more sense to me.

I hope this helps a bit.

xarqi
Subject: Re: pascal programming
From: xarqi-ga on 03 Jun 2003 04:43 PDT
 
I have to keep flying blind here.  What is the problem with the last
section?  A syntax error?  If so, what and where?  If not, what?  Did
the compiler just crash?
Subject: Re: pascal programming
From: xarqi-ga on 03 Jun 2003 04:47 PDT
 
Your variable declaration says "cutomers", not "customers"!
Subject: Re: pascal programming
From: xarqi-ga on 03 Jun 2003 05:00 PDT
 
Procedure calculation is not called.  You'd better watch out in there
too.  You have a parameter called accountype, butthis is also the tag
of a field in your record.  Which one the compiler actually uses in
inside the "with" could be a lottery.  My guess is that you don't need
the parameter at all.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy