The Henry Used Car Dealership
March 15, 2019
This is simple:
(define (henry) (display "Enter the sale price: ") (let ((sale (read))) (display "Enter the purchase price: ") (let ((purch (read))) (display "Profit is ") (display (- sale purch)) (newline) (display "Thanks for using this program.") (newline))))
> (henry) Enter the sale price: 1100 Enter the purchase price: 800 Profit is 300 Thanks for using this program.
You can run the program at https://ideone.com/XSZrYU.
HIPO charts are so 1970s. A more modern exercise would require an 11-way multiple-inheritanced class hierarchy.
It does seem a little old-fashioned. This book seems to be the source: https://books.google.co.uk/books?id=s72HJL9Z-4AC&pg=PT97
Here’s a Haskell version. Its only trick is that it will prompt repeatedly until you enter a valid amount.
Here’s a solution in Python.
Example Usage: