M04 Assignments

Introduction

The lessons for M04 concentrate on lists, so every program should include a list to hold temporary data.

M04_Assignments

M04 Exercise #1 (Analyze Vacation Packages)

The objective of this program is to read a file and store the data in a list.

You work for a travel agency that specializes in vacation packages to Europe.

Create a program that reads the VacationPackages.csv file and stores the data in one or more lists. Allow the user to enter a city name and then search the lists to see if your agency has a package for that city. If so, display the Country, City and Price for that package. Allow the user to enter another city or quit the program. The program should check to make sure the user's entry is not blank. The user should be able to search for a package as many times as they want. If the city is not found, display a message indicating that there are not packages currently available for that destination.

Output example:

M04 Assn 1 Exercise #1 Sample Output

Figure 1: M04 Assn 1 Exercise #1 Sample Output


M04 Exercise #2 (Find Country Vacation Packages)

The objective of this program is to read a file, store the data in a list, then search the list. This is very similar to Exercise #1.

Create a program that reads the VacationPackagesExtra.csv file and stores the data in one or more lists. Allow the user to enter a country name and then search the lists to see if your agency has one or more available packages for that city. (The first field in each row of the file contains "1" for available and "0" for not available.) If there are available packages, display the City and Price for each city package, sorted by city name. (The input file is not in a specific order.) Allow the user to enter another country or quit the program. The program should check to make sure the user's entry is not blank. The user should be able to search for a package as many times as they want. If the country is not found, display a message indicating that there are not packages currently available for that destination.

Output example:

M04 Assn 1 Exercise #2 Sample Output

Figure 2: M04 Assn 1 Exercise #2 Sample Output


M04 Exercise #3 (Summarize Vacation Packages)

The objective of this program is to read a file, aggregate the data, and present the count and average price for each country. This is very similar to Exercise #2.

Create a program that reads the VacationPackagesExtra.txt file and stores the data in one or more lists. No user entry is needed for this program. The program will count the number of available packages for each country and calculate the average price for selecting one of the package for each country. (The first field in each row of the file contains "1" for available and "0" for not available.) The program output should be a list of countries, sorted by country name, displaying how many packages are available and the average price for those packages.

Output example:

M04 Assn 2 Exercise #3 Sample Output

Figure 3: M04 Assn 2 Exercise #3 Sample Output