Question

In: Computer Science

Ruby Problem Create a template for an email letterhead with the following variables. The letter head...

Ruby Problem

Create a template for an email letterhead with the following variables. The letter head will have format place holders for:

Company name

Street address

City, State and zip code

Telephone

Email

Web site URL

Use the array of data below to fill your template place holders:

Run your finished script and capture the output to a file named email_template.txt.

# Two pieces of data in one array (multi dimensional array)
contact_data = [
  ['Company 1','123 Main Street', 'Anytown','Anystate', 88888,'444-444-4444','[email protected]','https://company1.com'],
  ['Company 2','77 Market Street', 'San Francisco','California', 94111,'415-444-4444','[email protected]','https://company2.com']
]

######### CREATE YOUR EMAIL TEMPLATE HERE #########
email_template = ""

# Process the data one array at a time
contact_data.each do |arr|
   # your code goes here.
end

Your output should end up looking something like this:

  Company 1
  123 Main Street
  Anytown, Anystate 88888
  Tel: 444-444-4444
  Email: [email protected]
  URL: https://company1.com

------------------------------

  Company 2
  77 Market Street
  San Francisco, California 94111
  Tel: 415-444-4444
  Email: [email protected]
  URL: https://company2.com

------------------------------

Solutions

Expert Solution

Answer

# Two pieces of data in one array (multi dimensional array)
contact_data = [
['Company 1','123 Main Street', 'Anytown','Anystate', 88888,'444-444-4444','[email protected]','https://company1.com'],
['Company 2','77 Market Street', 'San Francisco','California', 94111,'415-444-4444','[email protected]','https://company2.com']
]

######### CREATE YOUR EMAIL TEMPLATE HERE #########
email_template = ""

# Process the data one array at a time
# Loop over each row array.
contact_data.each do |arr|
# Loop over each cell in the row.
puts arr[0]
puts arr[1]
puts arr[2]<<", "<<arr[3]<<" "<<arr[4].to_s
puts "Tel : "<<arr[5]
puts "Email : "<<arr[6]
puts "URL : "<<arr[7]
# End of row.
puts "----------------------------"
end

OUTPUT


Related Solutions

Ruby programming Create a Ruby program which reads numbers, deposits them into an array and then...
Ruby programming Create a Ruby program which reads numbers, deposits them into an array and then calculates the arithmetic mean (otherwise known as the average), the median (that is, the number that splits the set of value in half with half being above and half being below the number), and the standard deviation (that is, the average of distance each number is from the mean then squared). Further information about these calculations can be found here: average: http://en.wikipedia.org/wiki/Average (add up...
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter)...
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter) based on the writing prompt. Topic: What are the effects of modern technology on children?
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter)...
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter) based on the writing prompt. Topic: What are the effects of modern technology on children?
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter)...
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter) based on the writing prompt. Topic: What causes a person to become an excellent student?
Develop a promotional message. This can be an email, letter, or any other relevant material that...
Develop a promotional message. This can be an email, letter, or any other relevant material that answers why should students take a Professional Communications course.
Your Professional Experience assignment is to develop a promotional message. This can be an email, letter,...
Your Professional Experience assignment is to develop a promotional message. This can be an email, letter, info graphic, image, or any other relevant material that answers why should students take a Professional Communications course.
Task # 1: Create Network Diagrams for the following: sending a letter including the following activities:...
Task # 1: Create Network Diagrams for the following: sending a letter including the following activities: Write letter Put in envelope Address letter Place stamp on letter Post letter Provide the answer with explanation.
Excel HW 4: Fox Lake Networking Template Objective: Create a template to estimate the cost of...
Excel HW 4: Fox Lake Networking Template Objective: Create a template to estimate the cost of networking Fox Lake Country Club. Skills: IF, AND, OR, COUNT, COUNTA, and COUNTIF and Conditional formatting For the past year, members at Fox Lake Country Club have been complaining about not being able to access the Internet or slow data transmission speeds while at the club. Given your knowledge of spreadsheets, Jeff Lewis, business manager at Fox Lake, has asked you to create an...
Create a C++ program that consists of the following: In maincreate the following three variables:...
Create a C++ program that consists of the following: In main create the following three variables: A char named theChar A double named theDouble An int named theInt Fill each of these variables with data taken as input from the keyboard using a single cin statement. Perform the following task on each variable: Increment theChar by one Decrement theDouble by two Square theInt This should be done on separate lines. Output the value of each variable to the screen on...
Create by yourself a Linear Programming problem with at least 3 decision variables and 3 constraints....
Create by yourself a Linear Programming problem with at least 3 decision variables and 3 constraints. Solve the problem using the simplex method
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT