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

Username:   Password: 
 RegisterRegister   
 Urgent Turing Calculator Help
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Wajih




PostPosted: Tue Jan 11, 2011 11:26 pm   Post subject: RE:Urgent Turing Calculator Help

i read it and somewhat understand it now. i amstill trying to comprehend it some parts. i put my code inside the loop with the mousewhere and got the desired effect. the only thing now is how do you make the make the turing machine recognize what kind of number the mouse is at. and how to display it on the screen.



if (x >= 196) and (x < 210) and (y > 237) and (y < 259) then
put "8"

end if

i tried that. but it still does not show the answer in the box at the top. also how do i store the number. like for example say if the user enters a number, i want the number to be stored. do i have to put the num after the "8" or something like that
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Jan 11, 2011 11:33 pm   Post subject: RE:Urgent Turing Calculator Help

You would probably want to put that number into some kind of a variable; then you could work with the values in your variables.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Wajih




PostPosted: Tue Jan 11, 2011 11:50 pm   Post subject: RE:Urgent Turing Calculator Help

see i did that. i put it into the num variable which is a real.

but it still says "8 false"

if (button = 1) and( x >= 196) and (x < 210) and (y > 237) and (y < 259) then
locate ( 5, 19)
put "", 8, (num = 8)
end if

do you have any idea why it says false
Tony




PostPosted: Tue Jan 11, 2011 11:55 pm   Post subject: RE:Urgent Turing Calculator Help

what is the value of num at that point?
code:

put "", 8, (num = 8), " num is: ", num


What is the difference between real and int?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Wajih




PostPosted: Wed Jan 12, 2011 5:34 pm   Post subject: RE:Urgent Turing Calculator Help

isnt int any whole number?
and real is any number, either a whole number or decimal
2goto1




PostPosted: Wed Jan 12, 2011 5:53 pm   Post subject: RE:Urgent Turing Calculator Help

An integer can be either positive or negative, whereas a whole number is 0 or greater.
Wajih




PostPosted: Wed Jan 12, 2011 6:26 pm   Post subject: RE:Urgent Turing Calculator Help

i made the necessary corrections to the code. now the thing is how do i make the numbers for num 2 appear because every time i hit a number it only goes to num. does anyone know why?


var num : real
var num2 : real := 0
var symbol : string
var x , y , button : int := 0




loop
Mouse.Where (x, y, button)
Text.Locate (22, 1)
if button = 0 then
put x : 0, " ", y : 0, " button up"
else
put x : 0, " ", y : 0, " button down"
end if



if (button = 1) and ( x >= 137) and ( x <= 158) and ( y >= 142) and ( y <= 163) then
locate (5, 19)
num := 1
put "", num
end if

if ( button = 1 ) and ( x >= 194) and (x <= 214) and ( y >= 142) and ( y <= 163) then
locate (5, 19)
num := 2
put "", num
end if

if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 142) and ( y <= 163) then
locate (5, 19)
num := 3
put "", num
end if

if ( button = 1 ) and ( x >= 137) and (x <= 158) and ( y >= 190) and ( y <= 208) then
locate (5, 19)
num := 4
put "", num
end if

if ( button = 1 ) and ( x >= 194) and (x <= 214) and ( y >= 190) and ( y <= 208) then
locate (5, 19)
num := 5
put "", num
end if

if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 190) and ( y <= 208) then
locate (5, 19)
num := 6
put "", num
end if

if ( button = 1 ) and ( x >= 137) and (x <= 158) and ( y >= 241) and ( y <= 258) then
locate (5, 19)
num := 7
put "", num
end if

if (button = 1) and( x >= 196) and (x < 210) and (y > 237) and (y < 259) then
locate (5, 19)
num := 8
put "", num
end if


if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 241) and ( y <= 258) then
locate (5, 19)
num := 9
put "", num
end if

if (button = 1) and( x >= 298) and (x < 333) and (y > 234) and (y < 266) then
locate (5, 30)
symbol := "="
put "", symbol
end if

if (button = 1) and( x >= 387) and (x < 405) and (y > 190) and (y < 210) then
locate (5, 22)
symbol := "*"
put "", symbol
end if

if (button = 1) and( x >= 345) and (x < 367) and (y > 188) and (y < 210) then
locate (5, 22)
symbol := "/"
put "", symbol
end if

if (button = 1) and( x >= 305) and (x < 325) and (y > 142) and (y < 163) then
locate (5, 22)
symbol := "-"
put "", symbol
end if

if (button = 1) and( x >= 305) and (x < 325) and (y > 190) and (y < 210) then
locate (5, 22)
symbol := "+"
put "", symbol
end if






drawbox (100, 100, 500, 475, red)
drawbox (128, 305, 470, 350, black)

locate (2, 32)
put "CALCULATOR" ..
locate (16, 19)
put "1" ..
locate (16, 26)
put "2" ..
locate (16, 33)
put "3" ..
locate (13, 19)
put "4" ..
locate (13, 26)
put "5" ..
locate (13, 33)
put "6" ..
locate (10, 19)
put "7" ..
locate (10, 26)
put "8" ..
locate (10, 33)
put "9" ..
locate (10, 40)
put "=" ..
locate (16, 40)
put "-" ..
locate (13, 40)
put "+" ..
locate (13, 45)
put "/" ..
locate (13, 50)
put "*" ..



drawoval (148, 151, 12, 12, black)
drawoval (205, 151, 12, 12, black)
drawoval (262, 151, 12, 12, black)
drawoval (148, 200, 12, 12, black)
drawoval (205, 200, 12, 12, black)
drawoval (262, 200, 12, 12, black)
drawoval (148, 249, 12, 12, black)
drawoval (205, 249, 12, 12, black)
drawoval (262, 249, 12, 12, black)
drawoval (316, 249, 20, 20, black)
drawoval (316, 200, 13, 13, black)
drawoval (316, 151, 13, 13, black)
drawoval (356, 200, 13, 13, black)
drawoval (396, 200, 13, 13, black)
drawfillbox (285, 100, 286, 300, black)



Mouse.Where (x, y, button)
Text.Locate (22, 1)
if button = 0 then
put x : 0, " ", y : 0, " button up"
else
put x : 0, " ", y : 0, " button down"
end if

if (button = 1) and ( x >= 137) and ( x <= 158) and ( y >= 142) and ( y <= 163) then
locate (5, 25)
num2 := 1
put "", num2
end if

if ( button = 1 ) and ( x >= 194) and (x <= 214) and ( y >= 142) and ( y <= 163) then
locate (5, 25)
num2 := 2
put "", num2
end if

if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 142) and ( y <= 163) then
locate (5, 25)
num2 := 3
put "", num2
end if

if ( button = 1 ) and ( x >= 137) and (x <= 158) and ( y >= 190) and ( y <= 208) then
locate (5, 25)
num2 := 4
put "", num2
end if

if ( button = 1 ) and ( x >= 194) and (x <= 214) and ( y >= 190) and ( y <= 208) then
locate (5, 25)
num2 := 5
put "", num2
end if

if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 190) and ( y <= 208) then
locate (5, 25)
num2 := 6
put "", num2
end if

if ( button = 1 ) and ( x >= 137) and (x <= 158) and ( y >= 241) and ( y <= 258) then
locate (5, 25)
num2 := 7
put "", num2
end if

if (button = 1) and( x >= 196) and (x < 210) and (y > 237) and (y < 259) then
locate (5, 25)
num2 := 8
put "", num2
end if


if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 241) and ( y <= 258) then
locate (5, 25)
num2 := 9
put "", num2
end if




drawbox (100, 100, 500, 475, red)
drawbox (128, 305, 470, 350, black)

locate (2, 32)
put "CALCULATOR" ..
locate (16, 19)
put "1" ..
locate (16, 26)
put "2" ..
locate (16, 33)
put "3" ..
locate (13, 19)
put "4" ..
locate (13, 26)
put "5" ..
locate (13, 33)
put "6" ..
locate (10, 19)
put "7" ..
locate (10, 26)
put "8" ..
locate (10, 33)
put "9" ..
locate (10, 40)
put "=" ..
locate (16, 40)
put "-" ..
locate (13, 40)
put "+" ..
locate (13, 45)
put "/" ..
locate (13, 50)
put "*" ..



drawoval (148, 151, 12, 12, black)
drawoval (205, 151, 12, 12, black)
drawoval (262, 151, 12, 12, black)
drawoval (148, 200, 12, 12, black)
drawoval (205, 200, 12, 12, black)
drawoval (262, 200, 12, 12, black)
drawoval (148, 249, 12, 12, black)
drawoval (205, 249, 12, 12, black)
drawoval (262, 249, 12, 12, black)
drawoval (316, 249, 20, 20, black)
drawoval (316, 200, 13, 13, black)
drawoval (316, 151, 13, 13, black)
drawoval (356, 200, 13, 13, black)
drawoval (396, 200, 13, 13, black)
drawfillbox (285, 100, 286, 300, black)
end loop
Tony




PostPosted: Wed Jan 12, 2011 6:57 pm   Post subject: RE:Urgent Turing Calculator Help

hard to tell for sure, but I don't think you are keeping track of the state that you are in. That is, when the loop is running, how do you know if the first number has already been selected or not?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Wajih




PostPosted: Wed Jan 12, 2011 7:22 pm   Post subject: RE:Urgent Turing Calculator Help

because it is displayed. the thing i need help is with how to make the first number(num), the symbol and the second number (num2) be seen at the same time. do i have to create a new variable? a new loop?
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 2 of 2  [ 24 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: