Input and conditinal statements.

--Originally published at Ricardo's Blog

This is a different type of program, most of the other ones were just to program something, and sit back so we coukd watch what the program run on its own.

Here is a different type of program, one that you can “interact” with, or just type some stuff that the program is asking us to.

bmi

First, we put in the program to ask the user a name, with the “input” tag, then we ask the question, and print “Hello, (whatever the name of the user is)”.

Second, we ask the user its age with the “input” thing again, but since we are gonna use that value later to print something depending on the users age. We put the “int” command so that the computer will use the age data as a number, not a string.

Then we ask if they want to know their BMI, if they type “no”, the program will end. If they type “yes” doesn’t matter if it’s on caps or anything, it’ll ask the next question. Which is “What’s your weight in kilograms?” again, with the “int” command, because we’ll be using calculations later.

When we ask the next question, “What’s you height in meters?”, instead of using the “int” command (which is only used for whole numbers) we use the “float” command, which also involves all numbers in between the whole numbers.

At the end, we only use the variables from each question, and create the BMI formula in out code, then print it. That should be it.

This video really helped me a lot, I’ve been watching this YouTube channel since we started. And it has really helped me. I hope it helps y’all as well.

Thank you for watching. Hope you enjoyed.

Byeeeeeeee.