Question: Assignment - Arrays - Road Trip You are going on a road trip with some friends. Make a Python program to collect all the data

Assignment - Arrays - Road Trip

You are going on a road trip with some friends.

Make a Python program to collect all the data of the trip and calculate each person share of the cost.


Prompt the user for the following:

  • The number of days of the trip.
  • The number of people on the trip.
  • For each day of the trip:
    • Cost of food.
    • Cost of gas.
    • NOTE: The prompts for cost of food and gas are for the entire group per day

Validate the all input (must be non-negative (i.e >= 0) You should be using a loop to validate. Be careful of you loop counter for the day loop.

The food and gas costs should be collected and stored in two separate arrays.

Display all data collected in the arrays. Optional: Display all data in tabular column form.


Calculate and display each of the following:

  • The total cost of each category(food, gas).
  • The total cost of the trip.
  • Each person's share of the total cost.


Your program must have at least three Functions where data is passed through arguments and returns.

No Globals.

  • One function to collect the costs array data
  • One function to display the costs array data
  • One or two functions to calculate and display the totals

Display your name,class,date as per SubmissionRequirements by using a function.

Your program should include Header comments (what the program does) and in-line comments (the major design steps).



I'm not sure how to lay out this assignment and write the code for it. This week we have learned more about arrays and loops so we still are using beginner Python coding in CMIS 102.

Step by Step Solution

3.38 Rating (145 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Program Road Trip Cost Calculator Description This program collects data for a road trip including the number of days number of people and the costs f... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!