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

Username:   Password: 
 RegisterRegister   
 Simple program i made
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mathwiz




PostPosted: Thu Nov 02, 2006 10:49 am   Post subject: Simple program i made

var number1 : real
var number2 : real
var total : int
var symbel : real
var number : real

put " please enter your first number"
get number1
put " please enter your lst number"
get number2

put " please enter number"
put " 1. Addition"
put "2. Subtraction"
put "3. Multiplication"
put "4. Division"
get number



if number = 1 then
put number1, "+ ", number2,"=", number1 + number2
elsif

number = 2 then
put number1, "-", number2,"=",number1-number2

elsif
number=3 then
put number1, "*",number2,"=", number1*number2

elsif
number= 4 then
put number1,"/",number2,"=", number1/number2

elsif
number>4 then
put "You have to enter a number between 1-4 not 5-10"
put "and you call yourself Smart."
end if
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Thu Nov 02, 2006 11:50 am   Post subject: (No subject)

Next thing you should do is learn procedures (or functions) and loops, then you can expand on your program.

What procedures/functions and loops will do for your program is, make it run more than once. Here's a small example of procedures and loops.

code:

var num1, num2, final :int
var done:int := 2

procedure add
    final := num1 + num2
    put "Final = ", final
end add

loop
    cls % Everything in loop starts here
    put "Enter num1: "
    get num1
    put "Enter num2: "
    get num2
   
    add %We call to "add" procedure, and everything in "add" gets done now

    put ""
    put "Again? 1 = yes, 2 = no
    exit when done = 2 %Exit loop if done = 2, if done not=2 then loop starts over
end loop
put "Bye."


Edit: Next time please use code tags like such Wink.

code:
[code]All code goes here.[/code]
abysspell




PostPosted: Fri Nov 03, 2006 1:51 pm   Post subject: (No subject)

Wow, thats an old thing. I completely forgot about it. You might want to check your output. it says to enter your first number twice.
rdrake




PostPosted: Fri Nov 03, 2006 2:27 pm   Post subject: (No subject)

abysspell wrote:
You might want to check your output. it says to enter your first number twice.
Awha? Try this.

Turing:
var num1, num2, final :int
var done:int := 2

procedure add
    final := num1 + num2
    put "Final = ", final
end add

loop
    cls % Everything in loop starts here
    put "Enter num1: "
    get num1
    put "Enter num2: "
    get num2
   
    add %We call to "add" procedure, and everything in "add" gets done now

    put ""
    put "Again? 1 = yes, 2 = no"
    get done
    exit when done = 2 %Exit loop if done = 2, if done not=2 then loop starts over
end loop
put "Bye."
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: