I am suppose to write a pseudocode for a calculator problem. This is what I got... The only thing I think I am really missing is "Your project should include a function/subprogram to check for a divide by zero error if the chosen operator is division." How do I do this?
function main(){
input();
calculation();
result();
} End main
function input(){
var number1 integer starts with 0
var number2 integer starts with 0
var operator string starts with ""
Ask for the first number, store in number1
Ask for the second number, store in number 2
Ask for the operator sign, store in operator
} End input
function calculation(){
if (operator == '+') then {result = number1 + number2;}
} End If
if (operator == '-') then {result = number1 - number2;}
} End If
if (operator == '*') then {result = number1 * number2;}
} End If
if (operator == '/') then {result = number1 / number2;}
} End If
} End calculation
function result(){
alert(result)
} End result
2007-11-02
09:54:47
·
2 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design
so I will need to make a new variable for it? var zeroDivide = 0?
2007-11-02
10:09:59 ·
update #1