Menu Problem. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Menu Problem. (/thread-11379.html) Pages:
1
2
|
Menu Problem. - Jim99 - Jul-05-2018 Hello guys, the idea of my project is self-explanatory by the menu. It is a menu for a hotel booking system. I am stuck on what to do next? How do I make a list of guests, etc. I need to know how the user of my code can enter people into a data table, can anyone help? ((BEGINNER PYTHON)) I have done this so far: def menu(): print("???????????????") print("?? A: Add new member ??") print("? B: Book a night. ??") print("?? C: Redeem points ??") print("? D: Show members. ??") print("?? E: Quit ??") print("????????????????") answer =str.lower(input(("Please select an option"))) if answer == "a": print("Okay, lets start") elif answer == "b": print("Okay, lets start") elif answer == "c": print("Okay, lets start") elif answer == "d": print("Okay, lets start") elif answer == "e": print("Exited") else: print("Invalid") menu()((Cheers)) RE: Menu Problem. - micseydel - Jul-06-2018 Do you have an actual homework description? It would be very helpful in cases like this. Do you know how you're supposed to store things? I would expect a dictionary. (In a non-intro course, it might be a database, or using JSON on disk.) Are you supposed to have that menu in a loop? RE: Menu Problem. - Jim99 - Jul-07-2018 (Jul-06-2018, 08:39 PM)micseydel Wrote: Do you have an actual homework description? It would be very helpful in cases like this. Itis for a hotel, to store members, create new bookings, etc. We are using while loops, I would like the simplest way of data storage so it can be displayed easily. Any ideas on nezt steps? We are supposed to use a lot of def functions. RE: Menu Problem. - micseydel - Jul-07-2018 I'd start with show members, which will do basically nothing. Then add member. Then test both against each other. I'd use either a dictionary or a list, depending on what you need (it's incredibly unclear from what you've provided). RE: Menu Problem. - Jim99 - Jul-08-2018 (Jul-07-2018, 12:37 AM)micseydel Wrote: I'd start with show members, which will do basically nothing. Then add member. Then test both against each other. I'd use either a dictionary or a list, depending on what you need (it's incredibly unclear from what you've provided). This is the question. There are no restrictions or guides. This is an exam style question. Can you please help me on how to advance from my current code? I am really stuck, Thanks The managers of Crawdale Hotel Group have decided to update their customer loyalty scheme. Customers joining the scheme become silver members. Customers are upgraded to gold members when they have booked 30 nights’ accommodation and to platinum once they reach 100 nights. Silver members receive 2500 loyalty points per night booked, gold members receive 3000 points and platinum members 4000 points. The data is stored as a text file. The data in this table is provided in the SampleData2017.txt file. Member ID Surname Year joined Membership status Nights booked Points balance Gri33415 Griffiths 2015 Gold 35 40000 Smi22316 Smith 2016 Silver 3 7500 Mia56213 Miah 2013 Platinum 140 165000 All78915 Allen 2015 Platinum 120 145000 Hug91714 Huggett 2014 Platinum 150 50000 Sel77617 Selby 2017 Gold 40 45000 San55614 Santus 2014 Silver 12 30000 Lee44213 Leewah 2013 Silver 15 37500 The loyalty points can be redeemed for nights at the hotels. A night costs 25000 points. Requirements The managers want a computer program to help them operate the scheme efficiently. The program must allow hotel staff to add new members to the scheme, record nights booked and points redeemed. It must also update a member’s points balance each time they book nights or redeem points, upgrade their membership status when appropriate and allow the number and status of the members to be monitored. The number of nights in a single booking must be limited to a maximum of 14. The program must allocate a unique ID to each new member consisting of the first three letters of their surname, plus a three-digit number, followed by the last two digits of the current year. Your task is to analyse these requirements and to design, implement, test and evaluate it RE: Menu Problem. - carpe - Jul-08-2018 If I were a student in an intro programming course and was given this assignment, this is roughly how I would go about approaching this problem. 1. Write a function that imports the data from some form of database and makes it usable. The prompt states it's stored as a text file, you are going to want to write a function that imports data from text files and stores it in the program to be manipulated. If I were writing this program, I would probably clean up the data some, and have it stored in a pandas data frame. There are a lot of other valid approaches to this, but it's probably what I would have done. 2. Write a different function to be able to write any changes to your dataframe back to your text file. Instead of trying to find out what had been changed, I'd probably just write function the overwrites your the text file with the information in the dataframe. 3. Once I had basic input-output out of the way, I would want to write a function that corresponds to each of your specified menu options.
Depending on how I wanted things to work, or how bulky the code got, I might break it down further. After that was all done, I would go through and make sure my code is well formatted, my comments made sense, and made sure my code worked. Finally, I would re-read the prompt and check my code to make sure I didn't miss any technical specifications asked for to avoid a point deduction. RE: Menu Problem. - Jim99 - Jul-08-2018 (Jul-08-2018, 03:26 AM)carpe Wrote: If I were a student in an intro programming course and was given this assignment, this is roughly how I would go about approaching this problem. Could you please give me a rough outline of option 1? To show me what I need to progress to. It would be much appreciated as I have small experience in python. RE: Menu Problem. - carpe - Jul-08-2018 Quote:Could you please give me a rough outline of option 1? To show me what I need to progress to. It would be much appreciated as I have small experience in python. Assuming the original text file looks something similar to... Member ID Surname Year Joined Membership Status Nights Booked Points Balance Gri33415 Griffiths 2015 Gold 35 40000 Smi22316 Smith 2016 Silver 3 7500 Mia56213 Miah 2013 Platinum 140 165000 ... tThen something like... import pandas as pd def read_text(): data_frame = pd.read_csv("/path/to/relevant/file/textfile.txt", sep=" ", skiprows=[0], header=None) data_frame.columns = ["Member ID", "Surname", "Year Joined", "Membership Status", "Nights Booked", "Points Balance"] return data_frame... should get the data loaded in and ready to use. RE: Menu Problem. - Jim99 - Jul-09-2018 (Jul-08-2018, 11:07 PM)carpe Wrote:Quote:Could you please give me a rough outline of option 1? To show me what I need to progress to. It would be much appreciated as I have small experience in python. Thank you! I shall try this now and report back with any issues. This is much appreciated. RE: Menu Problem. - Jim99 - Jul-09-2018 (Jul-08-2018, 11:07 PM)carpe Wrote:Quote:Could you please give me a rough outline of option 1? To show me what I need to progress to. It would be much appreciated as I have small experience in python. Where do I insert my version of the code you kindly provided in relation to my current code, and also how do I make it so that when the user selects the option to show all the members, this shows up. How do I link it to the relevant option? Cheers.: answer =str.lower(input(("Please select an option"))) if answer == "a": print("Okay, lets start") elif answer == "b": print("Okay, lets start") elif answer == "c": print("Okay, lets start") elif answer == "d": print("Okay, lets start") elif answer == "e": print("Exited") else: print("Invalid") menu() |