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 integer_math.rb
, we can write the command:
ruby integer_math.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.
If you divide the number of days in a regular year by the number of days in a week, what's the remainder?
Your output should be a number; for example,
4
It should ask the user to enter a number (using gets
) and output true
or false
if the entered number is odd.
Example (13
is the input):
"Enter an odd number:"
13
true
Example (12
is the input):
"Enter an odd number:"
12
false
Ask for a person’s age, and then calculate and display what year they were born in.
Input:
80
Key output: "Wow, you were born in 1940. You're old!"
Complete input and output example:
"How old are you?"
80
"Wow, you were born in 1940. You're old!"
Click here to see names of each test
integer_math.rb should output '1'
integer_odd.rb should output 'true' if the entered number is odd
integer_odd.rb should output 'false' if the entered number is not odd
integer_birth_year.rb should output'Wow, you were born in 1940. You're old!' if the input is 80.
integer_birth_year.rb should output'Wow, you were born in 1940. You're old!' if the input is 80.