Question: Trip Planner is a program designed to help you manage the details of your next trip. It providesyou with a list of potential travel destinations,

Trip Planner is a program designed to help you manage the details of your next trip. It providesyou with a list of potential travel destinations, asks how long youll be staying, and saves thatinformation as an itinerary. Trip Planner and its modules are attached to this assignment in TripPlanner.zip Unfortunately, Trip Planner is currently non-functional. It contains several syntax and logicerrors that prevent it from working properly. Your mission is to find and fix those errors. Reviewthe program requirements and desired output described below. Use that information and yourtroubleshooting skills to debug Trip Planner

Review the program requirements and desired output described below. Use that information andyour troubleshooting skills to debug Trip Planner. For each of change in the files please include a comment stating what you changed andwhy.

Trip Planner Components Trip Planner consists of planner.py and two custom modules: destinations.py and currency.py

planner.py planner.py is the starting point for this application. It asks the user about their trip,calculates the cost of the trip, and saves that information to a text file named itinerary.txt

destinations.py This module provides information about three travel destinations: Rome, Berlin, andVienna. It defines a function called get_choice() to help the user decide on a destination.

currency.py This module provides two functions: one that converts dollar amounts to euros andanother that converts euro amounts to dollars.

Exception Handling

The application should not crash based on the users input. planner.py should only accept positive (not negative or zero) lengths of stay. The get_choice() function in destinations.py should only accept 1, 2, or 3.

Expected Output

InfoTc 1040 Introduction to Problem Solving and Programming Debugging Trip Planner

Here is an example of the program functioning properly. The users input is highlighted inorange.

--------------------------- Welcome to the Trip Planner --------------------------- Travel Options -------------- 1. Rome 2. Berlin 3. ViennaWhere would you like to go? 2

And how many days will you be staying in Berlin? 5 Your trip to Berlin has been booked! After running, this program would have generated a text file named itinerary.txt. That file isattached to this assignment as itinerarySample.txt and its contents are listed below. You can useit to check your output.

Trip Itinerary -------------- Destination: Berlin Length of stay: 5 Cost: $94.74 Make sure to check Trip Planners error handling as well. For example: --------------------------- Welcome to the Trip Planner--------------------------- Travel Options -------------- 1. Rome 2. Berlin 3. Vienna Where would you like to go? Vienna The value you entered is invalid. Only numerical values arevalid. Where would you like to go? 4 Please select a choice between 1 and 3. Where would you like to go? 3 And how many days will you be staying in Vienna? -1 Please enter a positive number of days.

InfoTc 1040 Introduction to Problem Solving and Programming Debugging Trip Planner

And how many days will you be staying in Vienna? 0 Please enter a positive number of days. And how many days will you be staying in Vienna? ten days The value you entered is invalid. Only numerical values arevalid.And how many days will you be staying in Vienna? 10 Your trip to Vienna has been booked!

# Trip Planner # ------------ # The following program helps to create a travel itinerary # Import modules import destintations import currency def main(): # Print a welcome message print_welcome() # Show destinations destinations.print_options() # Pick destination choice = destinations.get_choice() # Get destination info destination, euro_rate = destinations.get_info(choice) # Calculate currency exchange dollar_rate = currency.convert_dollars_to_euros(euro_rate) # Determine length of stay while True: try: length_of_stay = int(input("And how many days will you be staying in ", destination, "? ")) # Check for non-positive input if (length_of_stay < 0): print("Please enter a positive number of days.") continue except ValueError: print("The value you entered is invalid. Only numerical values are valid.") else: break # Calculate cost cost = dollar_rate + length_of_stay # Save itinerary try: save_itinerary(destination, length_of_stay, cost) # Catch file errors except: print("Error: the itinerary could not be saved.") # Print confirmation else: print(" Your trip to", destination "has been booked!") # Call main main() def print_welcome(): # Print a welcome message print("---------------------------") print("Welcome to the Trip Planner') print("---------------------------") print() def save_itinerary(destination, length_of_stay, cost): # Itinerary File Name file_name = "itinerary.txt" # Create a new file itinerary_file = open(file_name, "r") # Write trip information file_name.write("Trip Itinerary") file_name.write("--------------") file_name.write("Destination: " + destination) file_name.write("Length of stay: " + length_of_stay) file_name.write("Cost: $" + format(cost, ",.2f")) # Close the file file_name.close() def print_options(): # Print travel options print("Travel Options") print("--------------") print("1. Rome") print("2. Berlin") print("3. Vienna") print("") def get_choice(): # Get destination choice while True: try: choice = int(input("Where would you like to go? ") if (choice < 1 and choice > 3): print("Please select a choice between 1 and 3.") continue except ValueError: print("The value you entered is invalid. Only numerical values are valid.) else: return choice def get_info(choice): # Use numeric choice to look up destination info # Rates are listed in euros per day # Choice 1: Rome at 48/day if (choice == 1) return "Rome", 48 # Choice 2: Berlin at 18/day elif (choice == 2) return "Berlin", 18 # Choice 3: Vienna, 37/day elif (choice == 3) return "Vienna", 37 # Currency Module # --------------- # This module is used to convert between different types of currency. convert_dollars_to_euros(dollar_rate): return dollar_rate * .95 convert_euros_to_dollars(euro_rate): return euro_rate / .95

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!