Please HAND write the following problem as a LISP program. It does not need to b
ID: 674193 • Letter: P
Question
Please HAND write the following problem as a LISP program. It does not need to be done in a compiler. (see extra credit) (10 points)
1) Begin the program
2) Declare 4 integer variables
3) Ask the user to enter the first number
4) Read the value in
5) Ask the user to enter the second number
6) Read the value in
7) Ask the user to enter the third number
8) Read the value in
9) The fourth variable is the product of the first three variables
10) output the fourth variable.
11) End the program
here is the code i wrote
(print “please enter the first number: “)
(defvar *num1* (read))
(print “please enter the second number: “)
(defvar *num2* (read))
(print “please enter the third number: “)
(defvar *num3* (read))
(format t (product of these 3 numbers is ~2f ~%” (* num1 num2 num3)
)
but can not run
can anybody fix my fault?
Explanation / Answer
(print “please enter the first number: “)
(defvar num1)
(defun my-function ()
(setq num1 (read))
(print “please enter the second number: “)
(defvar num2)
(defun my-function ()
(setq num2 (read))
(print “please enter the third number: “)
(defvar num3)
(defun my-function ()
(setq num3 (read))
(write (* num1 num2 num3)
)