I’m trying to do a calculation and it looks like this:

Inhale (ex. 30) minus Exhale (ex. 28) divide that by Exhale (ex. 28) and divide that by .1 to get .71

I’m using Firebase for the authentication and the database. I want the user to fill out the inhale and exhale numbers and spit out a percentage when the calculate button is clicked.

Could I please get some help around the right blocks I need to use to make that calculation. If i’m using Firebase for the storage I would use cloud variables correct?

I don’t understand your math. What is exhale/exhale/.1? Wouldn’t that just be 1/.1 which equals 10?

Can you provide a link to a description of the equation and/or some sample values so I can understand the equation better? I think there may be some missing parentheses.

Does this help? A person would take their measurements during a breathing exercise to get the numbers to input into the inhale and exhale fields.

The calculation is:

Take your inhale number (ex. 30) and subtract from your exhale number (ex. 28). Take the result of that and divide by your exhale number (ex. 28) and then divide by .1 to get 0.71.

The grades are not too hard to do but not something I can explain on my phone.

If you multiply 0.71… by 100 and place that inside a Round block from the Math drawer, you’ll get an integer. Then, optionally, you can use the Join block in the Text drawer to add “%” to the end.

You’re welcome. Your percent—>grade question is typically solved with an if/else if/else if… set of blocks. But it can also be solved with a series of stacked if blocks. Create two variables called percent and grade. Set percent to the value you calculated (such as 71%). Then set up this (I’m using sample values… your actual ranges may be different):

Edit: Oops! I originally had these in the wrong order. It should be:

If percent <= 100 then set grade to A
If percent < 90 then set grade to B
If percent < 80 then set grade to C
If percent < 70 then set grade to D
If percent < 60 then set grade to F