Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Bank program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vdragon88




PostPosted: Tue Jan 13, 2004 6:40 pm   Post subject: Bank program

I'm trying to make a bank program...

It starts off with a login with a pin#...
Then there are 4 options...
1.Deposit
2.Withdraw
3.View Balance
4.Exit

The default balance is $500.00

I wasnt able to make a deposit then withdraw(vice versa) and look at the balance to see that its updated. If I make one way work, the other wont work... I keep getting errors like: "balance" is not a procedure hence cannot be used.

Plz help me
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Jan 13, 2004 6:42 pm   Post subject: (No subject)

well you see... balance is not a procedure. It's probably a variable Confused Try using
code:

put balance


I donno Confused some details will be nice, such as what type of variable balance is, and maybe the line of code that generated the error
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
shorthair




PostPosted: Tue Jan 13, 2004 6:57 pm   Post subject: (No subject)

just give some background , this program is very straight forward ,

Il write the whole thing for you , if you lick your monitor and then rub your nose on the power supply while its on? Very Happy
Cervantes




PostPosted: Tue Jan 13, 2004 6:59 pm   Post subject: (No subject)

I hope your not suggesting he do those 2 things at once... that would hurt. Laughing
DanShadow




PostPosted: Tue Jan 13, 2004 7:33 pm   Post subject: (No subject)

It wouldnt hurt to do both those at once... *cough*.. I suggest trying it, it could prove useful. Like, you never know if its good until you try it, and if its bad, you've learned an valuable and painful lesson. Twisted Evil
And seriously, next time you post, please put a little "snippet" of your code specifically a couple lines before and after where your error shows up, you'll probably get easier results, heh. But Tony is most likely right, balance is more than likely a variable in your code, so your trying to turn a variable into a procedure, which cant be done...and make sure you dont have a procedure and a variable with the same name...that could cause difficulties, heh.
Maverick




PostPosted: Tue Jan 13, 2004 7:37 pm   Post subject: (No subject)

This program doesnt seem that hard. Post your code.
Andy




PostPosted: Tue Jan 13, 2004 7:57 pm   Post subject: (No subject)

give us what u have so far and we'll fix it
vdragon88




PostPosted: Wed Jan 14, 2004 2:39 pm   Post subject: (No subject)

%Author: Victor Tran
%Description:Bank account application that can be used by a bank machine.
%Filename: Bankacc.t


setscreen ("graphics.vga")
const username:="Victor"
const pwd:="830"
var uname:string
var passw:int
var count:=0
var win:=Window.Open("position:top,center,graphics:1000;700")
Draw.Box (980,0,680,0,1)
Draw.Fill (970,680,1,1)
procedure userLogin
loop
put "Username..."
get uname

if uname=username then
return
else
put "Invalid username. ';'';'"
count +=1
end if

if count=3 then
loop
put "You have tried 3 times and could not get in. Please try another day.... XD (|-| 4 X 0 12) XD!"
delay(1000)
Window.Close(win)
end loop
end if
end loop
end userLogin

procedure userPwd
loop
put "Password..."
get passw

if passw=830 then
put "Smile Login succesful Smile"
return
else
put " Access Denied! ';'';'"
count +=1
end if

if count=3 then
loop
put "You have tried 3 times and could not get in. Please try another day.... XD (|-| 4 X 0 12) XD"
delay (1000)
Window.Close(win)
end loop
end if
end loop
end userPwd

userLogin
userPwd
cls
Draw.Box (980,0,680,0,3)
Draw.Fill (970,680, 3,3)
Draw.FillMapleLeaf(50,175,250,300,4)
Draw.FillMapleLeaf(260,175,450,300,4)
const identifier := 4

Music.Play ("ee-ee-edc<a")
Music.Play ("ceab")
Music.Play ("ea-b>c")
Music.Play ("eee>ee-ee-edc<a")
Music.Play ("ceab")
Music.Play ("e>c<ba")


put " ************************************************************************"
put " * *** Welcome to Canadian Banking *** *"
put " * *"
put " * 1. Making a Deposit *"
put " * 2. Make a Withdrawal *"
put " * 3. View Balance *"
put " * 4. Exit *"
put " * *"
put " ************************************************************************"

var choice: int
var dChoice:= 1
var wChoice:= 2
var vChoice:= 3
var damount: real
var wamount: real
var balance: real

loop
put "Please make a selection:"
get choice

if choice = dChoice then
put "Enter deposit amount..."
get damount
if damount < 1000 then
put damount - (damount* .02)
put "Your balance is now:", 500 + (damount - (damount* .02))
balance:= 500 + damount
end if
end if

if choice = wChoice then
put "Enter Withdrawal Amount"
get wamount
if wamount >= 500 then %Sorry but withdraw only works if deposit is in Sad
put "Invalid"
end if
else if wamount < 500 then
put "Your new balance is now:", 500 - wamount
end if
end if

if choice = vChoice then
put "Your balance is:", 500 - wamount
end if

if choice = identifier then
put "Thank-you for Banking with Canadian Banking."
delay (1000)
exit
end if
end loop

^Here you go I dont know wuts wrong...
Thuged_Out_G




PostPosted: Wed Jan 14, 2004 4:12 pm   Post subject: (No subject)

code:

if wamount >= 500 then %Sorry but withdraw only works if deposit is in 
put "Invalid"
end if
else if wamount < 500 then
put "Your new balance is now:", 500 - wamount
end if
end if


change that to

code:

if wamount>=500 then
put "Invalid"
elsif wamount<500 then
put "Your new balance is now:",500-wamount
end if


and instead of saying if wamount>=500 ...make balance a variable and say
if wamount>=balance then
code here
end if

because what if the user wants to deposit first, and his balance is greater thne 500?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: