My First Ruby Program

So I finally know enough Ruby to make some shitty code run. I like Ruby so far; I still have a mountain of code to learn.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


class Dollar
 @@final_amount_per_day = 0
 @@final_amount_per_week = 0
 @@final_amount_per_two_weeks = 0
 @@final_amount_per_month = 0
 @@final_amount_per_year = 0
 @@final_amount = 0
 @@amount = 0
 def calculate()
 amount = 8.50 #Enter how much you get paid (per hour) here
 @@amount = amount

hours = 8.00 #Enter how many hours (per day) you work here
 per_day = amount * hours
 @@final_amount_per_day = per_day

days = 5.00 #Enter how many days (per week) you work here
 per_week = per_day * days
 @@final_amount_per_week = per_week

per_two_weeks = per_week * 2
 @@final_amount_per_two_weeks = per_two_weeks

weeks = 4.00 #Enter how many weeks (per month) you work here
 per_month = per_week * weeks
 @@final_amount_per_month = per_month

months = 12.00 #Enter how many months (per year) you work here
 per_year = per_month * months
 @@final_amount_per_year = per_year

annuity_per_year = 544.43 * 12
 all_income = per_year + annuity_per_year
 @@final_amount = all_income

puts "You get paid $#@@amount an Hour",
 "You make $#@@final_amount_per_day per Day",
 "You make $#@@final_amount_per_week per Week",
 "You make $#@@final_amount_per_two_weeks per two Weeks",
 "You make $#@@final_amount_per_month per Month",
 "You make $#@@final_amount_per_year per Year"

 link = "http://www.gmail.com"
 system("start #{link}")
 end
end

object = Dollar.new
object.calculate

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The result is :

You get paid $8.5 an Hour
You make $68.0 per Day
You make $340.0 per Week
You make $680.0 per two Weeks
You make $1360.0 per Month
You make $16320.0 per Year

And my browser opens gmail for no reason.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s