Ruby Basic Exercises: Test whether you are minor or not
Ruby Basic: Exercise-16 with Solution
Write a Ruby program to test whether you are minor (Consider a child unless he or she is less than 18 years old.) or not.
Ruby Code:
print "Input your age: "
age = gets.to_i
puts "You are a minor" unless age >= 18
Output:
Input your age: You are a minor
Flowchart:
Ruby Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Ruby program to create a new string from a given string where the first and last characters have been exchanged.
Next: Write a Ruby program to compute the absolute difference between n and 33 and return double the absolute difference if n is over 33.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework