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
- Host: GitHub
- URL: https://github.com/codeupjewell/ruby-float
- Owner: CodeUpJewell
- Created: 2023-03-08T03:10:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-08T03:11:31.000Z (about 3 years ago)
- Last Synced: 2025-01-21T18:49:22.694Z (over 1 year ago)
- Language: Ruby
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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

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'