Expense tracker program for three trips. How do I reference user input?

I am writing a travel expense program in Ruby where you would enter the amount spent on various things, transit, bags, etc. On three distinct trips to three different locations. (the program must include three separate trips) I would then like to use the input to perform calculations such as:

  1. Total cost of all trips combined
  2. Calculate percentage of total for each trip (example: your trip to Spain made up 50% of the total cost of all trips)
  3. Calculate all transit, and lodging totals
  4. return the most expensive trip.

I cannot figure out how to reference the user input to perform the calculations. I have only been able to output the amount spent on each trip (example: Spain : 1500, Hawaii : 2500, Egypt : 6500)

Please let me know if there’s anything I need to clarify. I am really struggling with this.

Here’s the gist:
gist:9f682070c5bdda23ffe5c81543dfa8ae

Your ‘gist’ is not a link, so I can’t see what you have done so far.

To ‘reference the user input’, in general you will store the value in a variable and use that variable’s value at a later point, e.g. by calling a method, or storing it in a class.

If you post more information, I might be able to help.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs