Thursday, July 18, 2019

Search a Persons Age Using Hashes in Ruby

Write a program uses hashes to ask the users the person name and then the program will search and display the person name in uppercase and display the corresponding age of the person on the screen.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Sample Program Output


Program Listing

search.rb


# search.rb
# Author   : Jake Rodriguez Pomperada,BSCS,MAED-IT
# Date     : July 16, 2019   Tuesday   7:07
# Address  : Bacolod City, Negros Occidental
# Tools    : Eclipse IDE and Ruby Version 2.6.3
# Location : Bacolod City, Negros Occidental  
# Website  : http://www.jakerpomperada.com
# Emails   : jakerpomperada@gmail.com and jakerpomperada@yahoo.com

  print "\n\n"
  print "\t===== Search a Persons Age Using Hashes ====="
  print "\n\n"
  people = %W[JAKE RUBY NORBERTO ALLIE JACOB JULIANNA LYDIA]
  ages = [41, 40, 28, 48, 6, 5, 77]
  input = ""
  position = 0
  print "\tEnter a name:  "
  input = gets.chomp
  position = people.index(input.upcase)
if position != nil then
   print "\n\n"
   print "\t#{people[position]} is already #{ages[position]} years old."
else
  print "\n\n" 
  print "\tI don't know who #{input.upcase} is."
end
print "\n\n";
print "\tEnd of Program"




No comments:

Post a Comment