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

Username:   Password: 
 RegisterRegister   
 TURING PROB PLZ HELP
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
help_wanted




PostPosted: Thu Jan 08, 2004 7:18 pm   Post subject: TURING PROB PLZ HELP

CAN SOME ONE HELP ME PLEASE IT KEEPS SAYING

THIS IS THE PROGRAM I WROTE AND WHEN I TRY TO RUN IT, IT SAYS:
operands of + must be both interger or real, compatible sets, or strings

const rn:="Prashanna"
const rp:="063"
var num1:int
var num2:int
var num4:int
var num3:int
var num5:real
var num6:real
var num01:="500"
var n:string
var p:string
var count:=0
var win:=Window.Open("position:top,center,graphics:500;400")

proc userLogin
loop
put "What is your Account name?"
get n

if n=rn then
put " "
return
else
put "Please try again"
count +=1
end if

if count=3 then
loop
Window.Close(win)
end loop
end if
end loop
end userLogin

proc userPwd
loop
put "Now enter your password"
get p

if p=rp then
put "Password Correct"
return
else
put "Please try again"
count +=1
end if

if count=3 then
loop
Window.Close(win)
end loop
end if
end loop
end userPwd

userLogin
userPwd
cls
put "Your balance is $500"
put "******************************************************"
put " ***Welcome to Thistletown Banking*** "
put " 1. Make a Deposit"
put " 2. Make a Withdrawal"
put " 3. View Balance"
put " 4. Exit the Program"
put "******************************************************"
put "Enter the number that you would like to do "..
get num1
cls
if num1 = 1 then
put "How much would you like to deposit $"..
get num5
delay (1000)cls
put "Your balance now is $", num01 + num5
end if
delay (2000)cls
put "******************************************************"
put " ***Welcome to Thistletown Banking*** "
put " 1. Make a Deposit"
put " 2. Make a Withdrawal"
put " 3. View Balance"
put " 4. Exit the Program"
put "******************************************************"
put "Enter the number that you would like to do "..
get num2
if num2 = 2 then
put "How much would you like to withdraw? "..
get num6
put "Your Balance now is ", num01 + num5 - num6
end if
if num6 < (num01 + num5) then
put "You exceeded your balance please try put in another amount"
end if
delay (2000) cls
put "******************************************************"
put " ***Welcome to Thistletown Banking*** "
put " 1. Make a Deposit"
put " 2. Make a Withdrawal"
put " 3. View Balance"
put " 4. Exit the Program"
put "******************************************************"
put "Enter the number that you would like to do "..
get num3
if num3 = 3 then
put num01 + num5 - num6
end if
delay (1500)cls
put "******************************************************"
put " ***Welcome to Thistletown Banking*** "
put " 1. Make a Deposit"
put " 2. Make a Withdrawal"
put " 3. View Balance"
put " 4. Exit the Program"
put "******************************************************"
put "Enter the number you would like to do "..
get num4
if num4 = 4 then
put "Thank you for using Thistletown Banking"
delay (1000) Window.Close(win)
end if
Sponsor
Sponsor
Sponsor
sponsor
Boarder16




PostPosted: Thu Jan 08, 2004 7:30 pm   Post subject: (No subject)

dude what r u trying to do... put 500 + num5 or make it so it shows teh total of what that equals????
Mazer




PostPosted: Thu Jan 08, 2004 7:44 pm   Post subject: (No subject)

the problem is that you're trying to add a number to a string.
num01 = "500" <-- a string, a "word"
num5 <-- a real, a "number"

either take off the quotation marks on 500 to make it an integer, or change

code:

put "Your balance now is $", num01 + num5


to
code:

put "Your balance now is $", strint (num01) + num5
Boarder16




PostPosted: Thu Jan 08, 2004 7:50 pm   Post subject: (No subject)

here you go... i changed quite a bit.. its all commented why and how bellow... it runs fine now.. teh simple problem was that u were trying to add a real numebr to an integer.. or sumthing liek that....
code:

const rn := "Prashanna"
const rp := "063"
var num1, num5, num6, balance : int %Added new variable balance for easier balance display..
var num01 : int := 500
var n, p : string % but variables of same type on same lines..saves space
var count := 0
var win := Window.Open ("position:top,center,graphics:500;400")
proc userLogin
    loop
        put "What is your Account name?"
        get n
        if n = rn then
            put " "
            return
        else
            put "Please try again"
            count += 1
        end if
        if count = 3 then
            loop
                Window.Close (win)
            end loop
        end if
    end loop
end userLogin

proc userPwd
    loop
        put "Now enter your password"
        get p
        if p = rp then
            put "Password Correct"
            return
        else
            put "Please try again"
            count += 1
        end if
        if count = 3 then
            loop
                Window.Close (win)
            end loop
        end if
    end loop
end userPwd

userLogin
userPwd
num5 := 0
balance := 500
/*Gave predefined values to variables so that no matter what they do it works..
 you had it so if they clicked balance right away it would be an error... aswell i made it so the small if
 statements became 1, saving you 3 variables.. and space.. also now the balance is regularly
 updated when ever tehy are done something.(It is hown at top of screen).. the small changes will make
 your program run alot better and efficient*/
loop
    cls
    put "Your balance is ", balance %variablesed balance so it shows an accurate balance
    put "******************************************************"
    put " ***Welcome to Thistletown Banking*** "
    put " 1. Make a Deposit"
    put " 2. Make a Withdrawal"
    put " 3. View Balance"
    put " 4. Exit the Program"
    put "******************************************************"
    put "Enter the number that you would like to do " ..
    get num1
    cls
    if num1 = 1 then %ALL ONE BIG IF STATEMENT>>IT SHOULD ALWAYS BE LIKE THIS....
        put "How much would you like to deposit $" ..
        get num5
        delay (1000)
        cls
        put "Your balance now is $", num01 + num5
        balance := num01 + num5 %Balance gets balue
        delay (2000)
        cls
        put "******************************************************"
        put " ***Welcome to Thistletown Banking*** "
        put " 1. Make a Deposit"
        put " 2. Make a Withdrawal"
        put " 3. View Balance"
        put " 4. Exit the Program"
        put "******************************************************"
        put "Enter the number that you would like to do " ..
    elsif num1 = 2 then
        put "How much would you like to withdraw? " ..
        get num6
        balance := num01 + num5 - num6 %Balance gets balue
        if num6 > (num01 + num5) then
            put "You exceeded your balance please try put in another amount"
        else
            put "Your Balance now is ", num01 + num5 - num6 % your greater then sign was the wrong way here lol
        end if
        /*Also you had it so that no matter what tehy did it would add to their balance...now
         only does if they ACTUALY HAVE the money they want*/
        delay (2000)
        cls
        put "******************************************************"
        put " ***Welcome to Thistletown Banking*** "
        put " 1. Make a Deposit"
        put " 2. Make a Withdrawal"
        put " 3. View Balance"
        put " 4. Exit the Program"
        put "******************************************************"
        put "Enter the number that you would like to do " ..
    elsif num1 = 3 then
        put balance %Displayes variable
        delay (1500)
        cls
        put "******************************************************"
        put " ***Welcome to Thistletown Banking*** "
        put " 1. Make a Deposit"
        put " 2. Make a Withdrawal"
        put " 3. View Balance"
        put " 4. Exit the Program"
        put "******************************************************"
        put "Enter the number you would like to do " ..
    elsif num1 = 4 then
        put "Thank you for using Thistletown Banking"
        delay (1000)
        Window.Close (win)
    end if
end loop
/*try to rememebr in the future that an optiosn menu like this should all be in one big if statement.. and
loop if it is always being used, seperate variables for each new action is a waste of time, and complicates
things, i take it you are new..so it is a VERY good start..*/


It wasn't that hard 4 me 8) , i am a genius.. its alot shorter and better.. u can add to it more..


P.S when the program is complete...post it 4 me to see ok... i'l lbe expecting good things from it lol...
Mazer




PostPosted: Thu Jan 08, 2004 7:58 pm   Post subject: (No subject)

holy crap, i'm going insane. when i first read help_wanted's program i thought it said "Welcome to Thistletown Bowling", and then when i read your program i noticed a proc about passwords and i just thought you posted in the wrong forum! Embarassed Razz Rolling Eyes
Andy




PostPosted: Fri Jan 09, 2004 9:24 pm   Post subject: (No subject)

and change ur topic name
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  [ 6 Posts ]
Jump to:   


Style:  
Search: