Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS 230

Introduction to Programming with Python

Fall 2023

Due 11:59 PM on Monday, November 20, 2023

Program 5: Girl Scout Fall Fundraiser

The local Girl Scout Troop in Waltham is holding a fall fundraiser. The fall fundraiser program enables

troops and individually registered members to earn startup funds

for the new membership year of the Girl Scouts by reaching out to

friends and family, asking for their support through the purchase of

nuts, chocolates, and other items. The list of items for this program

was inspired by the Girl Scouts of San Diego

(https://www.sdgirlscouts.org/en/cookies/for-cookie-

entrepreneurs/fall-product-program.html -- see “Meet our

Products”).

You have volunteered to help them develop a small Python-based system that allows them to store,  search, and manage their members and sales information. Girl Scouts often get their best sales while sitting in the “lobby” of supermarkets, so this program will keep track of product sales during these    periods of time.

The program reads in information about the members from a data file (members.txt) and another file  which is the sales transactions (transactions.txt). The first row is the column headings, and the rest of rows are the records in each file.

Everytime when the program runs, it first reads the information from the two files, and writes the

modified information from the program back to each file when the user exits the program. All changes to the information remain in the program (i.e., the dictionaries storing the information) while the program runs.

PROGRAM FUNCTIONALITY

The program provides the following capabilities:

ADD A MEMBER

Adds a member to the list of members. A member must be added to the program before making any   purchases. The information required includes the member’s lastname, first name, email address, city, and state. Assuming that member names are unique, the program will signal an error if a name,

meaning both the first name and lastname, is already taken.

Check for entry of a valid state and be sure to check that the email address is in a valid format. For this assignment, an email address is valid if it is a string that contains an @ sign and a dot (.) after the @

sign.

LIST THE MEMBERS

Displays all member records in a tabular format with appropriate column headings with the columns  aligned properly. The list is sorted alphabetically by the members’ last names. Use f-strings to display

the member information in the correct format.


  MAKE A PURCHASE


Allows a member to purchase products. The last and first name of the member need to be entered so the sales of the members can be tracked. This displays a list of the products on the catalog; asks the    user for the total number of products they wish to purchase; and then asks for each item and the

number of items. When the user is finished purchasing products, the total is added to the member’s sales.


  PURCHASES REPORT


Displays all purchases that members made during this session in a tabular format with appropriate column headings with the columns are aligned properly. Use f-strings to display the member

information in the correct format.


  SALES HISTORY REPORT


Displays the sales history in a tabular format with appropriate column headings with the columns are aligned properly. Use f-strings to display the  information in the correct format.


  QUIT


Displays a thank-you message and saves all updated member and transaction information to the respective files.

REQUIREMENTS:

•   Your program must fulfill all the tasks outlined above. See the sample output below to get more of an idea about how the program behaves. Your prompts and formatting should match what   is shown in the sample output.

•   The two data files are on Brightspace. Make sure your program can correctly read and write information from and to the files.

•   You may assume that all members have distinct last and first names.

•   Your program must be able to handle user errors (e.g., invalid options, wrong names, invalid

email address formats as described above.). For example, if a name is already in the troop when adding a member, the program should issue an error message that the name is already taken

and prompt for a new name.

•   The program should always return to the main menu after each task until the user wishes to quit.

HINTS:

•    Use two dictionaries for the information of members and transactions, respectively. For the

member dictionary, the key is the member’s last name, and the associated values can be placed in a list containing the member’s first name, email, city, and state. For the transaction

dictionary, the key is the member’s lastname and the associated values area list containing the member’s first name, total sales, and rewards.

•   To organize your program more effectively, you should use functions. For example, you may define a function, add_member() to add a new member; make_purchase() to allow the user to make a donation, etc. Be sure to include a main() function!

•    In addition to functions for each menu item, write as many functions as make sense for

repeated tasks such as isValidEmail(email) which returns True if the email is in a valid format.

Use the following standards for email address verification:

Format:namd@domain.extension

There should be one “@” and one “ .” (There might be a “ .” in the name, but we don’t consider that situation here). The indexof “@” and “ .” should be

. Neither zero

. Indexof the last “ .” > “@” + 1

GRADING

Your program should compile without syntax errors to receive any credit. If apart of your program is working, you will receive partial credit, but only if the program compiles without syntax errors.  This   assignment is scored on 50 points and contributes 12 percent of your course grade.

Number

Criteria

Points

1

Correctly read each line in each file and create appropriate data structure

10

2

Validation of user inputs for menu, existing name in member file, state, and email, and accepting both upper- and lower-case values for the

menus and options.

10

3

Output for menu options match those in the assignment.

10

4

Use of symbolic constants for filenames

2

5

Use of functions and main() function

10

6

Updated dictionaries written properly back to files

5

7

Coding style,including docstring, comments, variable names, etc.

3

 

Total:

50

SUBMISSION

Submit girlscout.py. Do NOT submit the two data files.