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

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




PostPosted: Thu Jan 13, 2011 8:22 pm   Post subject: RE:Calculator Questions

why would you get to state = 2?

doesnt state = 1 include all the operations for double, triple digit operations, etc? or for each additional digit you have to go to another state? if stage = 1, then how would output lets say 23?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jan 13, 2011 8:31 pm   Post subject: RE:Calculator Questions

As you are entering the first number, do you need different states for having already entered 1, 2, or 3 digits? If so, how are they different?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Wajih




PostPosted: Thu Jan 13, 2011 8:40 pm   Post subject: RE:Calculator Questions

im thinking you can add as many numbers as you want until you hit the second set of numbers
Tony




PostPosted: Thu Jan 13, 2011 9:18 pm   Post subject: RE:Calculator Questions

Indeed. As such, you need just a few general states.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Wajih




PostPosted: Thu Jan 13, 2011 9:49 pm   Post subject: RE:Calculator Questions

im sorry, i dont understand what you are trying to say. so if its a 6 digit number it should be in state 5? but first, if its in state = 1, how would you output a number?
Tony




PostPosted: Thu Jan 13, 2011 9:59 pm   Post subject: Re: RE:Calculator Questions

Wajih @ Thu Jan 13, 2011 9:49 pm wrote:
so if its a 6 digit number it should be in state 5?

Wajih @ Thu Jan 13, 2011 8:40 pm wrote:
im thinking you can add as many numbers as you want until you hit the second set of numbers
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Wajih




PostPosted: Thu Jan 13, 2011 10:20 pm   Post subject: RE:Calculator Questions

oh i get what you are saying now. but for displaying the number that you want, how do you do it? do you add num and num to get num?
Tony




PostPosted: Thu Jan 13, 2011 10:26 pm   Post subject: RE:Calculator Questions

Yes, almost. But if the first digit is 1 and second is 2, you want to get 1&2=12, not 1+2=3.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Wajih




PostPosted: Thu Jan 13, 2011 10:43 pm   Post subject: RE:Calculator Questions

then how would you do something like that? would you add to num, multiply it? i will send you a part of my code :

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

do i have to change the num?
Tony




PostPosted: Thu Jan 13, 2011 10:48 pm   Post subject: RE:Calculator Questions

if you had 1 and there was another number entered, then that 1 should become 10 before the second number is added in, right?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Wajih




PostPosted: Thu Jan 13, 2011 10:52 pm   Post subject: RE:Calculator Questions

right, but how would it become 10? because its already given a value of 1 right? is there a code that allows a value to be added right before a second number is clicked?
Tony




PostPosted: Thu Jan 13, 2011 11:01 pm   Post subject: RE:Calculator Questions

for example, you can do things like
code:

var num:int := 2
num := num + 1
put "num is now: ", num


When you click that second button, you know what num was before and you know what button was clicked, so you have enough information to figure out what num should become.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Wajih




PostPosted: Thu Jan 13, 2011 11:20 pm   Post subject: RE:Calculator Questions

when you mean the second button, you mean 2 right?

and when you know mean "you know what num was befor and you know what button was clicked" you are talking about 1 and 2 right? so 1 and 12 will equal 12.

but how do i write that into my program? because i already assigned num a value of real and 0.
Tony




PostPosted: Thu Jan 13, 2011 11:25 pm   Post subject: RE:Calculator Questions

you can assign num a new value; see the example above.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Wajih




PostPosted: Thu Jan 13, 2011 11:47 pm   Post subject: RE:Calculator Questions

see i did that but when i entered 1 and then 2, it erased the one Sad , do you want me to send you my code so you can see the problem?
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 4  [ 55 Posts ]
Goto page Previous  1, 2, 3, 4  Next
Jump to:   


Style:  
Search: