Day 2.2 Exercise 5 More Variables and Printing

Here’s my work on GitHub.
Here’s the link to exercise 5.

Ex05 Code
Exercise 5 Code
Ex05 Shell
Exercise 5 Output on Shell

Study Drills

1. Change all the variables so there is no my_ in front of each one. make sure you change the name everywhere, not just where you used = to set them.

2. Try to write some variables that convert the inches and pounds to centimeters and kilograms. Do not just type in the measurements. Work out the math in Ruby.
I converted it just fine, however not to the desired decimal points, so I’ve googled some more into this.

Ex6a Code
New ways to do rounded numbers.

Here are a few ways to do rounding numbers.
1. .round(#) – rounding to desired #
2. .floor – rounding down to the closes integer.
3. .ceil – rounding up to the closes integer.
4. ‘%.2f’% –  I was working on my height, the outcome was 165.1, so how do I make it to 165.10? I found this to work pretty well, it rounds (up and down) to the closes number.

There are more ways to do so, however it requires making a new class, which I find it too inconvenient, unless you need to specifically round up or down a number. Here’s the link to read more. Here’s another link.

Ex6a Shell
Output for my “rounding” test.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s