help wiht simple turing calculator (exe to code ?)
Author |
Message |
kousha41564
|
Posted: Mon Dec 08, 2008 3:57 pm Post subject: help wiht simple turing calculator (exe to code ?) |
|
|
hi i am new to turing , and sometimes when i am searching the net i see great programs. the only way i learned to start programing wiht turing was the fact taht i knew HTML and Basic. both are kinda similar so i just used my former knowledge to learn turing. but sometimes i wanna do somethign adn i have no idea how to go at it. then i find a great program whihc does what i want, i would love to study it, and learn how the person used the code. but apperently turing exe files are not viewable as code . so is there a way to turn exe into code ?
if not, i am making a calculator currently and all i got is somehting that requires you to put spaces between each part of the calculatiopn i.e 2 + 2 , and it can only accept two variebles and + - * / . could anyone help me on this one ? to make a more advanced calculator ?
code: |
var checklist : int := 0
var c1 : string
var num1 : real
var memory : string := "ABC"
var num2 : real
var answer : real := 0
var checklist2 : int := 0
loop
checklist := 0
if checklist2 < 1 then
put "please enter the equation (include spaces between each part of the equation)"
get num1, c1, num2
end if
if checklist2 > 1 then
num1 := answer
end if
if checklist2 > 1 then
put "please enter the equation (the first digit is asumed as ", answer, ")"
get c1, num2
end if
if c1 = "*" then
answer := num1 * num2
put num1 * num2
elsif c1 = "/" then
answer := num1 / num2
put num1 / num2
elsif c1 = "+" then
answer := num1 + num2
put num1 + num2
elsif c1 = "-" then
answer := num1 - num2
put num1 - num2
end if
put "would you like to clear memory ? (y/n) "
get memory
loop
if memory = "y" then
answer := 0
checklist2 := 0
checklist := 1
end if
if memory = "n" then
put "alright"
checklist2 := 2
checklist := 1
end if
put " "
put "memory is ", answer
exit when checklist = 1
end loop
end loop
|
please dont hate on it since its the first program i wrote :S. so if anyone could help me get over the add spaces between each part of the equation thing , i would be happy. also how do i make it so it does more tahn just 2 variebles at a time? TY |
|
|
|
|
|
Sponsor Sponsor
|
|
|
andrew.
|
Posted: Mon Dec 08, 2008 4:12 pm Post subject: RE:help wiht simple turing calculator (exe to code ?) |
|
|
You can't get the source code from an EXE for Turing or any other programming language. Once it's compiled, it's done.
About your program, you use multiple variables for different things. What if you just had one variable that was a string and the use enters in the whole equation. Then you use string manipulation to separate the numbers from the operations. Just look up string manipulation in the Turing Walkthrough. |
|
|
|
|
|
gitoxa
|
Posted: Mon Dec 08, 2008 4:18 pm Post subject: RE:help wiht simple turing calculator (exe to code ?) |
|
|
code: | get StringVariable : * |
That gets an entire line in turing into one variable, as opposed to just one word |
|
|
|
|
|
|
|