Last active
April 22, 2021 21:14
-
-
Save nikasulo/4f147e2149aa97266cfbb17c5c118fbf to your computer and use it in GitHub Desktop.
Billable hours–Stack Overflow – https://stackoverflow.com/questions/67218435/ruby-how-do-you-add-data-into-a-nested-array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def display_billable_hours(entries) | |
entries.each do |key, value| | |
puts "#{key}:" | |
puts value | |
end | |
end | |
def handle_input | |
days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] | |
entries = {} | |
days.each do |day| | |
while true | |
p "Enter your invoice number for #{day}:" | |
invoice_number = gets.chomp | |
break if invoice_number.length > 0 | |
end | |
while true | |
p "How many hours did you work on #{day}?:" | |
hours_worked = gets.chomp | |
break if hours_worked.length > 0 | |
end | |
entries[day] = "##{invoice_number} - #{hours_worked} Hours" | |
end | |
entries | |
end | |
def do_audit | |
entries = handle_input | |
display_billable_hours(entries) | |
end | |
do_audit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment