Recap Exercise

In case you get stuck anywhere, don't be afraid to ask the coaches! They are here to help and will gladly explain everything to you!

Take notes during the exercises. Even if you never look at them again, they will help you memorise things!

For these exercises, you will use your editor (Visual Studio Code or similar).

First, create an empty file with a meaningful name for this exercise, for example bmi.rb. Note the file extension .rb! Also remember what folder you saved your file in. It makes sense to create a folder for each lesson of the course.

Then, use cd in the command line to change to that folder. When you run ls you should see your file there.

Now you can run your Ruby program with ruby bmi.rb in the command line.

Repeat the above steps and remember to save your file in the editor before running it!

Write a program that lets the user calculate his/her body mass index (BMI). The user will be asked for their weight in kg and their height in m and the program calculates the BMI from that and outputs it. Here’s what an interaction with your program could look like:

Example interaction (user-entered text is bold):

What's your weight in kg?
What's your height in m?
Your BMI is 24.69864962817794

Extra credit: Round that ugly long floating point number to 2 digits after the comma!