Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Calculator (School Assignment)
Author Message
vexd

Posted: Sun Oct 05, 2003 4:58 pm   Post subject: Calculator (School Assignment)

%|------------------------------------------------------->
%|Author: VeXD
%|Date: Sept, 24 2003
%|Purpose: To make a simple calculator
%|Input: A operator and 2 integers, depending on the operator.
%|Output: This program will output the total of the integers.
%|------------------------------------------------------->

var rlNum : real := 0
var rlNum1 : real := 0
var strOperator : string

loop
put "Please Type in a valid operator or type OFF to exit."
loop
get strOperator
exit when strOperator = "sqrt" or strOperator = "abs" or strOperator
= "round" or strOperator = "+" or strOperator = "-" or strOperator
= "*" or strOperator = "/" or strOperator = "div" or strOperator =
"mod" or strOperator = "**" or strOperator = "off"
put "Invalid Operator, Please type a valid Operator or type OFF, to turn off the calculator."
end loop
exit when strOperator = "off" or strOperator = "OFF"

case strOperator of
get rlNum
label "sqrt" :
loop
exit when rlNum > 0
put "Please enter a positive number."
get rlNum
end loop
rlNum := sqrt (rlNum)
label "abs" :
rlNum := abs (rlNum)
label "round" :
rlNum := round (rlNum)
label "+" :
put "+" ..
get rlNum1
rlNum := rlNum + rlNum1
label "-" :
put "-" ..
get rlNum1
rlNum := rlNum - rlNum1
label "*" :
put "*" ..
get rlNum1
rlNum := rlNum * rlNum1
label "/" :
put "/" ..
get rlNum1
loop
exit when rlNum1 > 0
put "Please re-enter a new number"
get rlNum1
end loop
rlNum := rlNum / rlNum1
label "div" :
rlNum := round (rlNum)
put "div" ..
get rlNum1
loop
exit when rlNum1 > 0
put "Please re-enter a new number"
get rlNum1
end loop
rlNum1 := round (rlNum1)
rlNum := rlNum div rlNum1
label "mod" :
rlNum := round (rlNum)
put "mod" ..
get rlNum1
loop
exit when rlNum1 > 0
put "Please re-enter a new number"
get rlNum1
end loop
rlNum1 := round (rlNum1)
rlNum := rlNum mod rlNum1
label "**" :
put "**" ..
get rlNum1
loop
exit when rlNum1 > 0
put "Please re-enter a new number"
get rlNum1
end loop
rlNum := rlNum ** rlNum1
end case
put "---"
put rlNum
end loop

poly

Posted: Sun Oct 05, 2003 7:06 pm   Post subject: (No subject)

Whats the difference between this one and the other one you posted?
Dan

Posted: Sun Oct 05, 2003 8:54 pm   Post subject: (No subject)

i whould remomend hiting F2 befor copying this in to a post msg and if you put it in code tages it makes it look alot bet for poleop to see on the site.

any how, intresting progame why dont you try to make one where the user can put in somting like "5 + 6" in one input line and use substrings to tell what the oprator and values are.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Tony

Posted: Sun Oct 05, 2003 9:39 pm   Post subject: (No subject)

didn't bugz made something like that?
Tony's programming blog. DWITE - a programming contest.
vexd

Posted: Tue Oct 07, 2003 10:03 pm   Post subject: (No subject)

hehe guys i didnt make this for fun or anything, this was a assignment part of 3 that we get every week for comp sci. So, i didnt have to make dis complex or anything and i did hit F2..it just messed up, ill do it next time and im posting this here so a begginer can use it for his class if he has to do something like this. I know alot of people in my class that were asking for help on this one, and since im a Lab Advisor, ill recommend them this site
Dan

Posted: Wed Oct 08, 2003 11:14 am   Post subject: (No subject)

vexd wrote:
....and since im a Lab Advisor, ill recommend them this site

oh i like that. here have some bits for helping to make this site bigger and help poleop with the evil langue that is turing
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 6 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: