Last active
September 21, 2020 23:33
-
-
Save solomoncarnes/de32e70afa92e1fcf083137fabeab360 to your computer and use it in GitHub Desktop.
Travel Tracker (Original)
This file contains hidden or 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
# Trip one destination # | |
print "Hello, What was your destination for trip one? ==>" | |
trip_1 = gets.chomp | |
puts | |
# Trip one input # | |
print "Input round-trip transit expenses for your #{trip_1} trip ==> " | |
transit_1 = gets.chomp.to_f | |
puts | |
print "Input cost of lodging for your #{trip_1} trip ==> " | |
lodging_1 = gets.chomp.to_f | |
puts | |
print "How many bags did you check for your trip to #{trip_1}? ==>" | |
checked_1 = gets.chomp.to_f | |
# Checked bag calculation trip one # | |
bags_1 = checked_1 * 50 | |
puts | |
# trip two destinantion # | |
print "What was your destination for trip two? ==>" | |
trip_2 = gets.chomp | |
puts | |
# Trip two input # | |
print "Input round-trip transit expenses for your #{trip_2} trip ==> " | |
transit_2 = gets.chomp.to_f | |
puts | |
print "Input cost of lodging for your #{trip_2} trip ==> " | |
lodging_2 = gets.chomp.to_f | |
puts | |
puts | |
print "How many bags did you check for your trip to #{trip_2} ? ==>" | |
checked_2 = gets.chomp.to_f | |
# Checked bag calculation trip 2 # | |
bags_2 = checked_2 * 50 | |
puts | |
print "What was your destination for trip three? ==>" | |
trip_3 = gets.chomp | |
# Trip three input # | |
puts | |
print "Input round-trip transit expenses for your #{trip_3} trip ==> " | |
transit_3 = gets.chomp.to_f | |
puts | |
print "Input cost of lodging for your #{trip_3} trip ==> " | |
lodging_3 = gets.chomp.to_f | |
puts | |
print "How many bags did you check for your trip to #{trip_3}? ==>" | |
checked_3 = gets.chomp.to_f | |
# Checked bag calculation trip three # | |
bags_3 = checked_3 * 50 | |
# Calculating trip total costs # | |
puts | |
# Calculating trip one sum # | |
sum_1=transit_1+lodging_1+bags_1 | |
# Output total expenses trip 1 # | |
puts "The total cost for your #{trip_1} trip is: #{sum_1}" | |
# Calculating trip two Sum # | |
puts | |
sum_2 = transit_2+lodging_2+bags_2 | |
# Output total expenses trip 2 # | |
puts "The total cost for your #{trip_2} trip is: #{sum_2}" | |
# Calculating trip 3 sum # | |
puts | |
sum_3 = transit_3+lodging_3+bags_3 | |
# Output total expenses trip 3 # | |
puts "The total cost for your #{trip_3} trip is: #{sum_3}" | |
# Calculating all trips # | |
sum_4 = sum_1+sum_2+sum_3 | |
puts | |
# output all trips calculation # | |
puts "The total cost for all trips is: #{sum_4}" | |
# Calculating percentage of total for trip ONE # | |
# Calculating indv. trips by total trips * 100 # | |
puts | |
percentage_trip1 = sum_1.to_f/sum_4.to_f*100 | |
puts"Your trip to #{trip_1} made up #{percentage_trip1}% of the total cost of all trips" | |
# Calculating percentage of total for trip TWO # | |
# Calculating indv. trips by total trips * 100 # | |
puts | |
percentage_trip2 = sum_2.to_f/sum_4.to_f*100 | |
puts"Your trip to #{trip_2} made up #{percentage_trip2}% of the total cost of all trips" | |
# Calculating percentage of total for trip THREE # | |
# Calculating indv. trips by total trips * 100 # | |
puts | |
percentage_trip3 = sum_3.to_f/sum_4.to_f*100 | |
puts"Your trip to #{trip_3} made up #{percentage_trip3}% of the total cost of all trips" | |
puts | |
#Calculating transit total # | |
sum_transit = transit_1+transit_2+transit_3 | |
puts"You spent a total of $#{sum_transit} on transportation to #{trip_1}, #{trip_2}, and #{trip_3}." | |
puts | |
#Calculating Lodging total # | |
sum_lodging = lodging_1+lodging_2+lodging_3 | |
puts"You spent a total of $#{sum_lodging} on lodging in #{trip_1}, #{trip_2}, and #{trip_3}." | |
# calculating cost of most expensive trip # | |
total_cost = Array[sum_1,sum_2,sum_3] | |
puts | |
puts "Your most expensive trip was:" | |
if sum_1 == total_cost.max | |
puts "#{trip_1}" | |
elsif sum_2 == total_cost.max | |
puts "#{trip_2}" | |
else puts "#{trip_3}" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/chadmiller/da14731624c1ededb34acb645efee6f6