Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

InfoTc 1040 Introduction to Problem Solving and Programming Debugging Trip Planner Trip Planner is a program designed to help you manage the details of your

InfoTc 1040 Introduction to Problem Solving and Programming Debugging Trip Planner

Trip Planner is a program designed to help you manage the details of your next trip. It provides you with a list of potential travel destinations, asks how long youll be staying, and saves that information 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 logic errors that prevent it from working properly. Your mission is to find and fix those errors. Review the program requirements and desired output described below. Use that information and your troubleshooting skills to debug Trip Planner

Review the program requirements and desired output described below. Use that information and your troubleshooting skills to debug Trip Planner.

For each of change in the files please include a comment stating what you changed and why.

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, and Vienna. 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 and another 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 in orange.

--------------------------- Welcome to the Trip Planner --------------------------- 
Travel Options -------------- 1. Rome 2. Berlin 

3. Vienna

Where 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 is attached to this assignment as itinerarySample.txt and its contents are listed below. You can use it 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 are valid. 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 are valid. And how many days will you be staying in Vienna? 10 
Your trip to Vienna has been booked! 

The Python Program looks like these: (Needs helps debbuging the program)

# Trip Planner # ------------ # The following program helps to create a travel itinerary

# Import modules import destinations 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()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions

Question

How was their resistance overcome?

Answered: 1 week ago