### Scheme Executable Terminating Prematurely

Posted:

**Wed Apr 01, 2015 5:41 pm**The following program is my first scheme program that I designed to calculate the values of the variables in the compound interest formula and the compounded continuously formula. I used DrRacket to create an executable, but when I run it in Terminal (Mac), it ends after only the introduction (the part that displays the syntax) and doesn't allow the user to actually use the defined functions. How can I allow the executable to continue and allow the user to actually use the functions without simply stopping after the introduction?

#lang scheme

;INTRODUCTION

(display " a = balance, p = principle, r = rate,")

(newline)

(display " m = compounding periods, t = time")

(newline)

(newline)

(display "Compound Interest Formula:")

(newline)

(display "(solve-for-balance p r m t)")

(newline)

(display "(solve-for-principle a r m t)")

(newline)

(display "(solve-for-rate p a m t)")

(newline)

(display "(solve-for-time p a r m)")

(newline)

(display "(solve-for-principle a r m t)")

(newline)

(newline)

(display "Interest Compounded Continuously:")

(newline)

(display "(solve-for-balance-cont p r t)")

(newline)

(display "(solve-for-principle-cont a r t)")

(newline)

(display "(solve-for-rate-cont p a t)")

(newline)

(display "(solve-for-time-cont p a r)")

;COMPOUNDED INTEREST FORMULA

;Solve for Balance

(define (solve-for-balance p r m t)

(define part1

(+ 1 (/ r m)))

(define part2

(expt part1 (* m t)))

(display "$ ")

(display (* part2 p)))

;Solve for Principle

(define (solve-for-principle a r m t)

(define part1

(+ 1 (/ r m)))

(define part2

(expt part1 (* m t)))

(display "$ ")

(/ a part2))

;Solve for Rate

(define (solve-for-rate p a m t)

(define part1

(expt (/ a p) (/ 1 (* m t))))

(display (* 100 (* m (- part1 1))))

(display " %"))

;Solve for Time

(define (solve-for-time p a r m)

(define part1

(log (expt (/ a p) (/ 1 m))))

(define part2

(log (+ 1 (/ r m))))

(display (/ part1 part2))

(display " years"))

;INTEREST FORMULA COMPOUNDED CONTINUOUSLY

;Defining Euler's Number (e)

(define e 2.7182818284590452353602874713527)

;Solve for Balance (Compounded Continuously)

(define (solve-for-balance-cont p r t)

(display "$ ")

(expt (* p e) (* r t)))

;Solve for Principle (Compounded Continuously)

(define (solve-for-principle-cont a r t)

(display "$ ")

(/ a (expt e (* r t))))

;Solve for Rate (Compounded Continuously)

(define (solve-for-rate-cont p a t)

(display (*(/ (log (/ a p)) t) 100))

(display " %"))

;Solve for Time (Compounded Continuously)

(define (solve-for-time-cont p a r)

(display (/ (log (/ a p)) r))

(display " years"))

#lang scheme

;INTRODUCTION

(display " a = balance, p = principle, r = rate,")

(newline)

(display " m = compounding periods, t = time")

(newline)

(newline)

(display "Compound Interest Formula:")

(newline)

(display "(solve-for-balance p r m t)")

(newline)

(display "(solve-for-principle a r m t)")

(newline)

(display "(solve-for-rate p a m t)")

(newline)

(display "(solve-for-time p a r m)")

(newline)

(display "(solve-for-principle a r m t)")

(newline)

(newline)

(display "Interest Compounded Continuously:")

(newline)

(display "(solve-for-balance-cont p r t)")

(newline)

(display "(solve-for-principle-cont a r t)")

(newline)

(display "(solve-for-rate-cont p a t)")

(newline)

(display "(solve-for-time-cont p a r)")

;COMPOUNDED INTEREST FORMULA

;Solve for Balance

(define (solve-for-balance p r m t)

(define part1

(+ 1 (/ r m)))

(define part2

(expt part1 (* m t)))

(display "$ ")

(display (* part2 p)))

;Solve for Principle

(define (solve-for-principle a r m t)

(define part1

(+ 1 (/ r m)))

(define part2

(expt part1 (* m t)))

(display "$ ")

(/ a part2))

;Solve for Rate

(define (solve-for-rate p a m t)

(define part1

(expt (/ a p) (/ 1 (* m t))))

(display (* 100 (* m (- part1 1))))

(display " %"))

;Solve for Time

(define (solve-for-time p a r m)

(define part1

(log (expt (/ a p) (/ 1 m))))

(define part2

(log (+ 1 (/ r m))))

(display (/ part1 part2))

(display " years"))

;INTEREST FORMULA COMPOUNDED CONTINUOUSLY

;Defining Euler's Number (e)

(define e 2.7182818284590452353602874713527)

;Solve for Balance (Compounded Continuously)

(define (solve-for-balance-cont p r t)

(display "$ ")

(expt (* p e) (* r t)))

;Solve for Principle (Compounded Continuously)

(define (solve-for-principle-cont a r t)

(display "$ ")

(/ a (expt e (* r t))))

;Solve for Rate (Compounded Continuously)

(define (solve-for-rate-cont p a t)

(display (*(/ (log (/ a p)) t) 100))

(display " %"))

;Solve for Time (Compounded Continuously)

(define (solve-for-time-cont p a r)

(display (/ (log (/ a p)) r))

(display " years"))