%declaration Section
var num1, num2, num3 : int
var input : string
%Program Title
proc title
locate (1, 30)
put "Math testing program"
put " "
end title
%program introdution
proc intro
title
put "This program will do all four math functions with three numbers entered by you"
end intro
%User Input
proc userInput
locate (5, 1)
put "Enter an integer: " ..
loop
get input
exit when strintok (input)
put "Please enter an integer"
end loop
num1 := strint (input)
put "Enter a second integer: " ..
loop
get input
exit when strintok (input)
put "Please enter an integer"
end loop
num2 := strint (input)
put "Enter a second integer: " ..
loop
get input
exit when strintok (input)
put "Please enter an integer"
end loop
num3 := strint (input)
end userInput
%Output - Math Calculation & Chart Titles
proc display
var answer : real
locate (8, 30)
put "Math equation " : 15, "Result"
%Addition
answer := num1 + num2 + num3
locate (10, 30)
put num1, " + ", num2, " + ", num3 : 10, " = ", answer
%Substraction
answer := num1 + num2 - num3
locate (11, 30)
put num1, " + ", num2, " - ", num3 : 10, " = ", answer
%Multiplication
answer := num1 + num2 * num3
locate (12, 30)
put num1, " + ", num2, " * ", num3 : 10, " = ", answer
%Division
answer := num1 + num2 / num3
locate (13, 30)
put num1, " + ", num2, " / ", num3 : 10, " = ", answer
end display
intro
userInput
display
%End of program
|