An open API service indexing awesome lists of open source software.

https://github.com/codeupjewell/ruby-float

Showcasing floats in Ruby
https://github.com/codeupjewell/ruby-float

Last synced: about 1 year ago
JSON representation

Showcasing floats in Ruby

Awesome Lists containing this project

README

          

# Ruby Practice

Run your Ruby file by typing `ruby ` and then the name of the file you want to run in the Terminal.

If we want to run `float_round.rb`, we can write the command:

```bash
ruby float_round.rb
```

To re-run this command, you can use the UP and DOWN arrow keys to look at the history of commands you've run in a Terminal.

## Float
### float_find_hypotenuse.rb
A right triangle's two shorter sides have length `2.8` and `4.5`. Write a program to calculate how long its longest side is and print it.

Remember: the Pythagorean Theorem says that

![pythagorean therum](pythagorous.png)

where `a` and `b` are the lengths of the shorter sides, and `c` is the length of the longest side.

Your program should output a number; for example,

```bash
5.3
```

Read more about the formula: https://www.mathsisfun.com/pythagoras.html
### float_rounding.rb
Write a program that calculates 10 divided by 3 and rounds the result to 3 decimal places. The program should print this result.

```bash
3.333
```

## Specs

Click here to see names of each test

float_find_hypotenuse.rb should output '5.3''

float_round.rb should output '3.333'