
-----------------------------------
vexd
Sun Oct 05, 2003 4:58 pm

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
	    put "Please Enter your first number"
	    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
Sun Oct 05, 2003 7:06 pm


-----------------------------------
Whats the difference between this one and the other one you posted?

-----------------------------------
Dan
Sun Oct 05, 2003 8:54 pm


-----------------------------------
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.

-----------------------------------
Tony
Sun Oct 05, 2003 9:39 pm


-----------------------------------
didn't bugz made something like that?

-----------------------------------
vexd
Tue Oct 07, 2003 10:03 pm


-----------------------------------
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
Wed Oct 08, 2003 11:14 am


-----------------------------------
....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  :P
