Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
help plz
Author Message
pheonix3000

Posted: Mon Feb 17, 2003 11:28 am   Post subject: help plz

This is sort of a banking thing. i am not able to get through it. It keeps giving me errors at elsif iNum. Plz help me. any more stuff that i can add.
thx.

var iBalance : int := 0
var iDeposit : int
var iWithdraw :int
var iTotald : int := 0
var iTotalw : int:= 0
var again : string (1)
var leave : string (1)
var iNum : int
loop
put "Please enter a number greater than -500"
get iNum
if iNum > 0 then
iDeposit := iDeposit + iNum
iTotald := iTotald + 1
iBalance := iBalance + iDeposit
elsif iNum < 0 then
iWithdraw := iWithdraw -1
iTotalw := iTotalw + 1
iBalance := iBalance - iWithdraw
elsif iNum:= 0 then
put "You have deposited" , iDeposit
put "your Total Deposits are " , iTotald
put "you have withdrawn" , iWithdraw
put "your Total Withdraws are " , iTotalw
put "your balance is" , iBalance
end if
put "Go again (y/n)"
getch (again)
exit when again = "n" or again = "N"
put "exit (y/n)?"
getch (leave)
exit when leave = "y" or leave = "Y"
end loop

Dan

Posted: Mon Feb 17, 2003 11:52 am   Post subject: = not :=

there are a few things wrong.

1st in the part

 code: elsif iNum := 0 then

it needs to be = not :=

 code: elsif iNum = 0 then

2nd you need to have iDeposit set to something (initialize) if you are going to add to it.

3rd you need to do initialize(set initial value) iWithdraw too or you will get a simliare error.

i dont think this progame is doing what it is suppost to do yet. it may help if you tell us more about what it is suppost to do.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
pheonix3000

Posted: Mon Feb 17, 2003 1:34 pm   Post subject: (No subject)

yeah, its is like the banking thing. Where you make all the transcations thingi. k here is the thing that works. i want to make a few modifications . like i want the beginnning part ie from the welcome to entering 0 to be there always and i want the rest of it to clear. i dont know where to put the cls . And in the final answer how do i make the withdraws to be positive.

var iBalance : int := 0
var iDeposit : int := 0
var iWithdraw :int := 0
var iTotald : int := 0
var iTotalw : int:= 0
var again : string (1)
var iGrandt : int := 0
var iNum : int

put "-|-Welcome. To deposit money enter positive numbers and to withdraw enter negative numbers"
put "When finished your transcations, you can view your balances by entering the number as 0"
put "Your balance is : ", iBalance
put "You have deposited : ", iDeposit
put "You have withdrawn : ", iWithdraw
put "Your total Deposits : ", iTotald
put "Your Total withdraws : ", iTotalw
put "Your GrandTotal is :", iGrandt
put ""
put "You may begin your transcations"
loop
put ""
put "Please enter a number: "
get iNum
cls
iGrandt := iTotald + iTotalw
if iNum > 0 then
iDeposit := iDeposit + iNum
iTotald := iTotald + 1
iBalance := iBalance + iDeposit
put "You have deposited \$ ", iDeposit
put ""
else
iWithdraw := iWithdraw -1
iTotalw := iTotalw + 1
iBalance := iBalance - iWithdraw
put "you have withdrawn \$ ", iWithdraw
end if
if iNum = 0 then
put "You have deposited " , iDeposit
put "your Total Deposits are " , iTotald
put "you have withdrawn" , iWithdraw
put "your Total Withdraws are " , iTotalw
put "your balance is " , iBalance
put "your Grand Total is" ,iGrandt
end if
put ""
put "Would you like to make another Transaction. (y/n)?"
getch (again)
exit when again = "n" or again = "N"
cls
end loop
pheonix3000

Posted: Mon Feb 17, 2003 2:30 pm   Post subject: (No subject)

i was also wondering how to make the entire background to be black and the text to be green. Can u change the font of text ??
Tony

Posted: Mon Feb 17, 2003 2:34 pm   Post subject: (No subject)

you can put the first part into a procedure and call that when you need it..

such as
 code: procedure money() put "tony is cool" end money

then you can run all the code inside that just by calling money()

as for the cls, you put that first, then output all the information after that...

such as

 code: loop cls money() %input...
Tony's programming blog. DWITE - a programming contest.
pheonix3000

Posted: Mon Feb 17, 2003 2:38 pm   Post subject: (No subject)

Yeah, but we didnt learn about the procedures and functions yet. So i have to stick to the long way, i wantd to ask you something. has anyone made anh program on Logo that like there is a turtle on the screen and you move it by giving commands?
Tony

Posted: Mon Feb 17, 2003 3:24 pm   Post subject: (No subject)

yes, you should have used out "forum search" function

http://www.compsci.ca/bbs/viewtopic.php?t=295
Tony's programming blog. DWITE - a programming contest.
pheonix3000

Posted: Tue Feb 18, 2003 10:01 am   Post subject: (No subject)

I was wondering.. how would you rotate an object. like in turing version 3, if i have to rotate an object to the right of 90 degrees how would i do that. Do u have to work with the x and y coordinates? or is there any special " for it code". if there isnt then what's the "format" code for doing so.

Tony

Posted: Tue Feb 18, 2003 10:58 am   Post subject: (No subject)

that depends on the object you want to rotate... and what you need to do that for.

Often you can just rotate your image at w/e angles you need before you load your program and then use one of those angles. (Might not work if you need very detailed rotations).
Tony's programming blog. DWITE - a programming contest.
pheonix3000

Posted: Tue Feb 18, 2003 11:08 am   Post subject: (No subject)

i didnt understand what you said, but it is for a program, where i am supposed to move a character depending on what the user says -- you know one of those chr (). yeah i wanted to rorate them to a 90 degrees
Tony

Posted: Tue Feb 18, 2003 12:43 pm   Post subject: (No subject)

< ^ > v

use those to rotate your object.
Tony's programming blog. DWITE - a programming contest.
pheonix3000

Posted: Wed Feb 19, 2003 9:49 am   Post subject: (No subject)

can u give an example?
Tony

Posted: Wed Feb 19, 2003 9:55 am   Post subject: (No subject)

umm...

put "^"

? or what do you mean?

if its facing up, you use ^ if right its > if down its v if left its <

depending on the location your character is fasing, you output different symbols.

because you can't take a "T" and rotate that
Tony's programming blog. DWITE - a programming contest.
pheonix3000

Posted: Wed Feb 19, 2003 12:35 pm   Post subject: (No subject)

i am not sure whether this is the correct thing or not. i tried to the way u told but it didnt quite work
 code: var sCommand : string         var sFwd : string := "f"         var sLft: string := "l"         var sRght : string:= "r"         var iDst : int                  var sQuit : string := "q"         var x : int := 15         var y : int := 15         var direction : int := 0         loop             locate(round(y),round(x))                 put "|"             locate(1,1)             put "please enter a command"                 get sCommand             if sCommand = sFwd then                 put "Please enter a distance"                 get iDst                 y := y - iDst                 put "|" , y ,x             elsif sCommand = sRght then                 get sCommand                 put "-"             elsif sCommand = sLft then                 put "|"                        end if             cls                     end loop
pheonix3000

Posted: Wed Feb 26, 2003 11:14 am   Post subject: (No subject)

hi. I wanted to know how to code this program. k the program is about a parking garage. k ur input he day, the time u have entered, and how many MINUTES you have parked and whether the user has a pass or not. then you would calculate : \$3.00 for every !/2 hr , \$25.00 fpr daily maximum, \$8.50 if u have a pass, \$8.00 if time id after 6 pm and \$7.00 on sunday. try to give me a pieceof code. for ex.

day: thursday
time entered : 9.00
time parked : 153 minutes

u have to calcuate the the price.