-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc.rb
executable file
·157 lines (112 loc) · 2.84 KB
/
calc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
puts 2+1
puts 3
puts 1.0 + 2.0
puts 2.0 * 3.0
puts 5.0 - 8.0
puts 9.0 / 2.0
puts 1+2
puts 2*3
puts 5-8
puts 9/2
puts "There are 8640 hours a year assuming the year has 365 days."
puts 51840*11
puts 60*8640
puts "There are 5184000 minutes in a decade!!! :)"
puts "I am 570240 seconds old!Strangly looking at this number I feel young!Hmmm..."
puts 1025*100000000
102500000000
puts "Our dear Author is 102,500,000,000 seconds old"
puts 3600/1025
puts "There are #{24 * 365} hours in a year."
puts "There are #{60 * 24 * 365 * 10} minutes in a decade."
puts "Ana is #{11 * 365 * 24 * 60 * 60} seconds old."
puts "our dear author is #{1025000000 / 60 / 60 / 24 / 365}"
#chapt3
puts "Hello."
puts "Ruby rocks."
puts "Nobody deserves a mime, Buffy."
puts "Snoopy says #%^?&*@!when he stubs his toe."
puts " "
puts ''
puts 'Hello, world'
puts ''
puts 'Good-bye.'
puts 'I like" + "apple pie.'
puts 'I like " + "apple pie.'
puts 'I like" + " apple pie.'
puts 'blink ' * 4
puts 12 + 12
puts '12' + '12'
puts '12 + 12'
puts 2 * 5
puts '2' * 5
puts '2 * 5'
puts 'You\'re swell!'
puts 'backlash at the end of a string: \\'
puts 'up\down'
puts 'up\\down'
puts''
puts "chapter 4"
puts'...you can say that again...'
puts'...you can sat that again...'
my_string = '...you can say that again...'
puts my_string
puts my_string
composer = 'Mozart'
puts composer + ' was "da bomb" in his day.'
composer = 'beethoven'
puts 'But I perfer ' + composer + ', personally.'
my_own_var = 'just another ' + 'string'
puts my_own_var
my_own_var = 5 * (1+2)
puts my_own_var
var1 = 8
var2 = var1
puts var1
puts var2
puts''
var1 = 'eight'
puts var1
puts var2
puts''
puts 'chapter 5!'
var1 = 2
var2 = '5'
puts var1.to_s + var2
puts var1 + var2.to_i
puts''
puts '15'.to_f
puts '99.999'.to_f
puts '99.999'.to_i
puts ''
puts '5 is my favorite number!'.to_i
puts 'Who asked you for 5 or whatever'.to_i
puts 'your momma did.'.to_f
puts''
puts 'stringy'.to_s
puts 3.to_i
puts 20
puts 20.to_s
puts '20'
puts "Hello there, and what\'s your name?"
name = gets.chomp
puts 'your name is ' + name + '? What a lovely name!'
puts 'pleased to meet you,' + name + '. :)'
puts''
puts "Hello there, and what\'s your first name?"
first_name = gets.chomp
puts 'your first name is ' + first_name + '? What a lovely first name!'
puts "what is your middle name?"
middle_name = gets.chomp
puts middle_name + ' is an awesome middle name!'
puts first_name + " what is your last name"
last_name = gets.chomp
puts last_name + " is a wonderful last name!"
puts first_name + middle_name + last_name +' is an excellent whole name!:)'
puts "What is your favorite number?"
fav_number = gets.chomp.to_i
puts " #{fav_number} is a cool favorite number:D"
puts " #{fav_number + 1} is a bigger and better number"
my_birth_month = 'August'
my_birth_day = 3.to_s
puts my_birth_month + my_birth_day + " is my birthday and month!"