## My first Ruby script!

It gives you the choice of calculating the area of a circle, rectangle, or triangle:

Code:
```#!/usr/bin/env ruby

# The Area Calculator
# Calculate the area of a variety of shapes

def circle()

# Calculate area and print it
print &quot;The area is &quot;, area, &quot;\n&quot;
exit
end

def rectangle()
# Get base and height
print &quot;Base: &quot;
base = STDIN.gets
base = Float(base.chop!)
print &quot;Height: &quot;
height = STDIN.gets
height = Float(height.chop!)

# Calculate area and print it
area = base * height
print &quot;The area is &quot;, area, &quot;\n&quot;
exit
end

def triangle()
# Get base and height
print &quot;Base: &quot;
base = STDIN.gets
base = Float(base.chop!)
print &quot;Height: &quot;
height = STDIN.gets
height = Float(height.chop!)

# Calculate the area and print it
area = (base * height) / 2
print &quot;The area is &quot;, area, &quot;\n&quot;
exit
end

# Start the script

print &quot;Area Calculator!\n\n&quot;
print &quot;Select a shape:\n&quot;
print &quot;1 Circle\n&quot;
print &quot;2 Rectangle\n&quot;
print &quot;3 Triangle\n\n&quot;
print &quot;? &quot;

# Get input - Which shape?
choice = STDIN.gets
# Catch exceptions when input is String or Float - exit
begin
choice = Integer(choice.chop!)
rescue
print &quot;Invalid selection\n&quot;
exit
end

print &quot;\n&quot;

# Calculate the area of the selection
# Catch exceptions when input in area calculations
# is String
begin
case choice
when 1
circle()
when 2
rectangle()
when 3
triangle()
end
rescue
end

# This is reached when an exception occurs above
# or when choice does not equal 1, 2, or 3
# Otherwise, the shape functions exit after area calculation
print &quot;Invalid Selection\n&quot;```
What do you think? A little sloppy? Should I add more shapes?

By the way, is there a default statement in Ruby (for the case statement)? And does anyone know of any good Ruby tutorials? I found like two of them, and they aren't very... super.