Instructions
Objective
Write a program to calculate BMI using DrRacket.
Requirements and Specifications
need a short code that calculates a BMI (body Mass index)
The formula I worked out is as follows
BMI = Weight(kg) / (height (cm) *height(cm)) x10000
Using DrRacket compiler I can input weight in kg and height in cm and get BMI result
Screenshots
Source Code
#lang racket
(define (read-weight)
(display "Weight (kg)?: ")
(read))
(define (read-height)
(display "Height (cm)?: ")
(read))
(define (bmi weight height)
(* 10000.0 (/ weight (* height height))))
(define (calculate-bmi)
(let ((x (bmi (read-weight) (read-height))))
(display "BMI: ")
(display x)
(display "\n")))