PROGRAM ATM3 (input, output);

	USES crt;
	CONST
		valid = 1234;

	VAR
		acctnum, transaction: integer;
		balance, amount: real;
	BEGIN

	acctnum:=0;
	transaction:=2;
	balance:=100.00;

	REPEAT
	     clrscr;
	     Writeln('What is your account number');
	     Writeln('Valid number is 1234');
     	      Readln(acctnum);
	UNTIL (acctnum=valid);

	clrscr;
	Writeln('Your current balance is ', balance:7:2);
	Writeln;
	Writeln('If you don''t want to use the ATM please');
               	Writeln('Enter in a zero amount for deposits and withdrawals');
	Writeln; 
	Writeln('Otherwise enter the transaction amount.');
	Writeln('Press return to continue');
	Readln;
	
	REPEAT		
		clrscr;
		Writeln('If you want to make a deposit enter the amount now');
		Writeln('Otherwise enter zero');
		Writeln('Enter in the amount in the form of');
		Writeln('         XXX.xx');
		Readln(amount);
		
		balance:=balance+amount;
		
		REPEAT
			clrscr;
			Writeln('If you want to make a withdrawal enter the amount now');
			Writeln('Otherwise enter zero');
			Writeln;
			Writeln('You cannot withdraw more than what your account contains');
			Writeln('Your current balance is ', balance:7:2);
			Writeln('Enter in the amount in the form of');
			Writeln('         XXX.xx');
			Readln(amount);
		UNTIL (amount <=balance) AND (amount >= 0);

		balance:=balance-amount;
		
		clrscr;
    		Writeln('Do you have another transaction to make?');
		Writeln;
		Writeln('        1 = yes for Deposits/Withdrawals');
		Writeln('        2 =  no for Quit');
		Writeln;
		Writeln('Your current balance is ', balance:7:2);
		Readln(transaction);

	UNTIL (transaction<>1);   {transaction = 2   -   so quit}

        	clrscr;
	Writeln('Goodbye');
	Readln;
	
	END.

	