1. Above each line. use the # to write a comment to yourself explaining what the line does.
Did that, but not all the lines, puts command are common sense now, right??? I did do the math with their brackets on, so I could tell what’s going on.
2. Remember in Exercise 0 when you started irb? Start irb this way again and using the math operators, use Ruby as calculator.
This starts off a little weird to me. Interactive Ruby Shell (irb). The author hasn’t explain much about how to use it, other than letting us know it is there. However, As you see above, that is the irb, how it should look like and what kind of error you’d get if you made a typo like me. To quit, simply type quit, which I forgot to include in the pic.
3. Find something you need to calculator and write a new .rb file that does it.
Unfortunately, I couldn’t find anything near me that I need to calculate at the time working on this.
4. Notice the math seems “wrong”? There are no fractions, only whole numbers. You need to use a “floating point” number, which is a number with decimal point, as in 10.5, or 0.89, or even 3.0.
Yes, that is due to data types as commented in the 1st picture. In older languages such as C++, it is required to declare what type of data being use. However in ruby, ruby does it for you as soon as you write it in decimal, so 1 would be int data type (integer), and 2.0 would be a float data type.
5. Rewrite ex3.rb to use floating point numbers so it’s more accurate. 20.0 is a floating point.
Look at the above comments for instructions on how to convert int to floating points.