Saturday, August 23, 2008

Times has Changed.

When I was 14-old year on the my test in school I had solving the second grade
equation Ax^2+bx+c=0 .
Now I solved it with AutoLISP .Check and you.

;;; Copyright (c) 2008 Ing.Arben Allaraj
;;; Program that solve equation of second grade.
;;; For more information contact to me.
;;; Modified by Bill Kramer.

(defun C:Grade2 ( / A B C D E F G)
(setq A (getreal "\nEnter the A value: ")
B (getreal " B value: ")
C (getreal " C value: ")
)
(cond
((zerop A)
(prompt "\nA value invalid, cannot be zero."))
((minusp (setq E (- (* B B) (* 4 A C))))
(prompt "\nB^2 - 4AC must be greater than zero to solve."))
(T
(setq D (+ (- B)(sqrt E))
F (/ D (* 2 A))
H (- (- B)(sqrt E))
G (/ H (* 2 A))
)
(prompt (strcat "\nSolution X1="
(rtos F)
", X2="
(rtos G)
))
)
)
(princ)
)