Arben.Allaraj
2008-06-20, 12:29 PM
I have passion on AutoLISP so I created this routine for Eq:ax2+bx+c=0
;;; Copyright (c) 2008 Ing.Arben Allaraj
;;; Program that solve equation of second grade.
;;; For more information contact to arben.allaraj@gmail.com
(defun c:grade2 ()
(Setq a(getreal"Give the a-value:"))
(setq b(getreal"Give the b-value:"))
(setq c(getreal"Give the c-value:"))
(if (= a 0)
(progn
(alert "a-value shouldn't be zero .")))
(setq e(-(* b b)(* 4 a c)))
(terpri)
(if (< e 0)
(progn
(alert "sorry but b2-4ac should be grater than zero.")))
(setq d (+ (- b)(sqrt e)))
(setq f(/ d(* 2 a)))
(princ (strcat"X1= "))
(princ f)
(setq h(- (- b)(sqrt e)))
(setq g(/ h(* 2 a)))
(princ (strcat"\nX2= "))
(princ g)
(princ)
)
(alert " This program is for solving equation of second grade.
ax2+bx+c=0
Type grade2 to run ... ")
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)
;;; Copyright (c) 2008 Ing.Arben Allaraj
;;; Program that solve equation of second grade.
;;; For more information contact to arben.allaraj@gmail.com
(defun c:grade2 ()
(Setq a(getreal"Give the a-value:"))
(setq b(getreal"Give the b-value:"))
(setq c(getreal"Give the c-value:"))
(if (= a 0)
(progn
(alert "a-value shouldn't be zero .")))
(setq e(-(* b b)(* 4 a c)))
(terpri)
(if (< e 0)
(progn
(alert "sorry but b2-4ac should be grater than zero.")))
(setq d (+ (- b)(sqrt e)))
(setq f(/ d(* 2 a)))
(princ (strcat"X1= "))
(princ f)
(setq h(- (- b)(sqrt e)))
(setq g(/ h(* 2 a)))
(princ (strcat"\nX2= "))
(princ g)
(princ)
)
(alert " This program is for solving equation of second grade.
ax2+bx+c=0
Type grade2 to run ... ")
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)