Skip to main content
留学咨询

辅导案例-1INFO1110

By May 15, 2020No Comments

Assignment 1INFO1110 / COMP9001 Money TrackerDeadline: 23rd Sept 2019, 11:59pm AEST (Week 8, Monday)Weighting: 10% of the final assessment markOverview Brief Description You will write a program that allows the user to manage their finances. The program will be ableto record the user’s incomes and expenses, display how their balance has changed, etc. It will alsoneed to be able to handle regular incomes and expenses; for example, the user will be able tospecify that they have a $100 income every Sunday, or that they spend $40.50 every Thursday.Implementation details Your program will be written in Python 3. The only modules you may import are sys and thefunction.py file which you will write yourself.Submission You will submit your code on the assignment page on Ed. To make a submission, you will need topress the “Mark” button. You may submit as many times as you wish without penalty – we willmark the last submission that you make. After each submission, the marking system willautomatically check your code against the public test cases.Please ensure you carefully follow the assignment specification. Your program output mustexactly match the output shown in the examples.Warning: Any attempts to deceive or disrupt the marking system will result in an immediate zerofor the entire assignment. Negative marks can be assigned if you do not properly follow theassignment specifications, or your code is unnecessarily or deliberately obfuscated.Help and feedback You are encouraged to ask questions about the assignment during the Helpdesk and on the Eddiscussion board; however, remember that you should not be posting any assignment codepublicly, as this would constitute academic dishonesty.The Program Starting the Program The program will be given 1 extra command line argument when it is run:This will specify a file with information about regular incomes and expenses; see thesection on Regular Transactions for more information (it is recommended that you implementthis feature last).After handling this file, the program will ask the user for their starting balance, like so:The user will then fill out this field with their initial balance, for example:If the starting value cannot be converted to a float, the program should print Error:Cannot convert to float! and quit immediately.If the starting value is negative or zero, the program should print Error: Must start withpositive balance! and quit immediately.Once we have the regular payments and initial balance set up, we’re good to go! The programshould now continually ask for input, like so:Depending on what the user enters, the program will record new transactions, show somestatistics, etc. For example, if the user types transaction ……then the transaction operation (explained below) should execute. The program shouldcontinue asking for more inputs indefinitely, and execute the appropriate code each time.$ python3 tracker.py Starting balance: $Starting balance: $4.11Starting balance: $catError: Cannot convert to float!Starting balance: $-5Error: Must start with positive balance!Enter command: Enter command: transactionOperations transaction Records a new income or expense transaction.The program should ask the user how much money was involved in the transaction, like so:The user should then be able to type in how much they earned or spent. Positive values representincome, and negative values represent expenses.This value should then be reflected in the user’s balance; for example, if they originally had $5 butmade a transaction of -$3, the user would now have $2.However, if the value the user types in cannot be converted to a float, the program should printError: Cannot convert to float! and ask for another command.next Advances to the next day, making sure the user is not in debt.If the user has strictly less than $0, the program should print Oh no! You’re in debt! and quitimmediately. Otherwise, it should print Going to the next day… and start a new day.In this program, we start at day 0 and increase the day number by 1 every time the nextcommand is executed.Enter amount: $Enter amount: $5.95Enter amount: $-2.35Enter amount: $catError: Cannot convert to float!Enter command: status Displays a summary of how the day is going so far.The program should print the following message:Here, is the current day number of the program. As explained above, this starts at0 and increases by 1 for every day that passes. is which weekday it currently is, abbeviated to three letters; Sun for Sunday,Mon for Monday, etc. In this program, day 0 is always a Sunday, day 1 is a Monday, and soon. Day 6 would be a Saturday and day 7 is a Sunday again. (The weekdays list in thescaffold may be useful here.) is the amount of money we had at the start of the day, before anytransactions (including regular transactions) were made. It should be displayed rounded toexactly 2 decimal places. is the amount of money we currently have, including all thetransactions we have made that day. It should be displayed rounded to exactly 2 decimalplaces.If the current balance is greater than the starting balance, the program should also print Nicework! You’re in the black. . Conversely, if the current balance is less than the startingbalance, the program should print Be careful! You’re in the red. . If the current balance isthe same as the starting balance, no extra message needs to be printed.Here are some examples:Day ()Starting balance: $Current balance: $Day 0 (Sun)Starting balance: $5.00Current balance: $6.00Nice work! You’re in the black.Day 5 (Fri)Starting balance: $55.00Current balance: $54.50Be careful! You’re in the red.Day 30 (Tue)Starting balance: $120.00Current balance: $120.00regular Displays a summary of the regular transactions.Please see the section on “Regular Transactions” to see how these values will be specified.The program should print Regular Transactions: ; then, for every weekday, the programshould show a summary of the regular transactions in the following format:Here, is the weekday abbreviated to three letters. is the income the user regularly earns for that weekday. It should bedisplayed rounded to exactly 2 decimal places. is the expense the user regularly has for that weekday. It should bedisplayed rounded to exactly 2 decimal places.Here is an example:help Shows a list of availabile commands.The program should print the following message:: +$ -$Regular Transactions:Sun: +$5.00 -$4.00Mon: +$3.00 -$2.00Tue: +$7.35 -$1.00Wed: +$0.00 -$0.00Thu: +$14.90 -$5.00Fri: +$6.00 -$3.00Sat: +$6.00 -$5.00The available commands are:”transaction”: Record a new income or expense”next”: Move on to the next day”status”: Show a summary of how you’re doing today”regular”: Show a summary of your regular transactions”help”: Show this help message”quit”: Quit the programquit Quits.The program should print Bye! and quit.Anything else If any command other than those specified above is entered, the program should simply print thefollowing message:The program should then continue prompting for commands.Regular Transactions Regular transactions are incomes and expenses that are automatically made on specific days ofthe week – for example, the user might always earn $100 on Sundays and spend $40.50 onThursdays, which the program should automatically process. To implement these regulartransactions, you need to follow these three steps:Step 1: Write the function process_file in the function.py file. This function should take onestring as an argument, open the file specified by this string and read the details of the regulartransactions described in this file. You can assume that the file will always be in the followingformat, with exactly 14 lines and each line being convertible to a float without error:All values in this file will be given as positive values; so if the user had a regular income of $100 onSundays and a regular expense of $40.50 on Thursdays, our file would look like this:Enter command: quitBye!Command not found.Use the “help” command for a list of available commands…The function should return a tuple of two lists, both of length 7; the first one being th
e regularincomes throughout the week, and the second one being the regular expenses throughout theweek.For example, if the string given to the function specified the file above, it should return ([100.0,0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 40.5, 0.0, 0.0]) . Make sureyour tuple contains lists of floats, not lists of strings.However,If the file specified by the parameter doesn’t exist, the function should raise a ValueErrorwith the content of that error being the message Error: String does not represent avalid file! .Step 2: At the start of your main code, use the process_file function to get the 2 listscontaining the details of the regular incomes and expenses. The filename to be used as theparameter for this function will be specified as a command line argument when running theprogram.You will need to make sure you include the line from function import process_file at thetop of your main code so that you can use the process_file function you wrote in part 1.However,If the required command line argument is not given, the program should print Error: Notenough command line arguments! and quit immediately.If the process_file function raises a ValueError, the program should print Error: Filenot found! and quit immediately.Step 3: Ensure your program automatically adds the regular income and subtracts the regularexpenses for the appropriate weekday at the start of every day.1000000000040.500000$ python3 tracker.py Examples Regular Transaction Files no_regular_transactions.txt :sample_regular_transactions.txt :0000000000000054327.3510014.956365Program Executions Normal Case 1: $ python3 tracker.py no_regular_transactions.txtStarting balance: $100.50Enter command: transactionEnter amount: $10Enter command: statusDay 0 (Sun)Starting balance: $100.50Current balance: $110.50Nice work! You’re in the black.Enter command: nextGoing to the next day…Enter command: statusDay 1 (Mon)Starting balance: $110.50Current balance: $110.50Enter command: regularRegular Transactions:Sun: +$0.00 -$0.00Mon: +$0.00 -$0.00Tue: +$0.00 -$0.00Wed: +$0.00 -$0.00Thu: +$0.00 -$0.00Fri: +$0.00 -$0.00Sat: +$0.00 -$0.00Enter command: transactionEnter amount: $-3Enter command: transactionEnter amount: $-10.2Enter command: statusDay 1 (Mon)Starting balance: $110.50Current balance: $97.30Be careful! You’re in the red.Enter command: quitBye!Normal Case 2: Invalid Command: $ python3 tracker.py sample_regular_transactions.txtStarting balance: $10.00Enter command: nextGoing to the next day…Enter command: nextGoing to the next day…Enter command: nextGoing to the next day…Enter command: nextGoing to the next day…Enter command: statusDay 4 (Thu)Starting balance: $18.35Current balance: $28.25Nice work! You’re in the black.Enter command: transactionEnter amount: $100Enter command: quitBye!$ python3 tracker.py no_regular_transactions.txt Starting balance: $5Enter command: STATUSCommand not found.Use the “help” command for a list of available commandsEnter command: exitCommand not found.Use the “help” command for a list of available commandsEnter command: quitBye!Going into Debt: Non-existent File $ python3 tracker.py no_regular_transactions.txtStarting balance: $5 Enter command: transactionEnter amount: $-10Enter command: statusDay 0 (Sun)Starting balance: $5.00Current balance: $-5.00Be careful! You’re in the red.Enter command: transactionEnter amount: $6Enter command: statusDay 0 (Sun)Starting balance: $5.00Current balance: $1.00Be careful! You’re in the red.Enter command: nextGoing to the next day…Enter command: transactionEnter amount: $-10Enter command: statusDay 1 (Mon)Starting balance: $1.00Current balance: $-9.00Be careful! You’re in the red.Enter command: nextOh no! You’re in debt!$ python3 tracker.py nonexistent.txtError: File not found!Unable to Interpret Transaction as Float Hints and Extra Information You should always print an empty line directly before asking the user for a command.Commands are case-sensitive. For example, quit is valid, but QUIT is invalid.To print a string containing single quotes, enclose it in double quotes, and vice versa (or puta backslash before it).Use the modulo operator ( % ) to your advantage. It can help you keep track of weekdays!For the purposes of this assignment, you can treat all monetary values as floats – none of thetest cases will cause floating point errors.$ python3 tracker.py no_regular_transactions.txt Starting balance: $10.50Enter command: transactionEnter amount: $catError: Cannot convert to float!Enter command: quitBye!Marking 7 marks will be given for passing the automated test cases. There are a total of 28 tests, andyou will receive 0.5 marks for every 2 that you pass (quarter marks will not be given).3 marks will be given for a manual inspection of code. You should ensure that your codeuses meaningful variable names, good structure, and helpful and concise comments toclarify the intentions of the code.Late Submissions Late submissions have a hard cap of 25% of the total possible marks per day late. For example, ifyour submission is 1 hour late, you can only receive a maximum of 75% for this assessment. Ifyour submission is 48 hours late, you can only receive a maximum of 50% for this assessment.Do not make any submissions after the deadline unless you want it to be counted as late.Remember, we will be marking the last submission you make.Academic declaration By submitting this assignment, you declare the following:I declare that I have read and understood the University of Sydney Student Plagiarism: CourseworkPolicy and Procedure, and except where specifically acknowledged, the work contained in thisassignment/project is my own work, and has not been copied from other sources or been previouslysubmitted for award or assessment.I understand that failure to comply with the Student Plagiarism: Coursework Policy and Procedure canlead to severe penalties as outlined under Chapter 8 of the University of Sydney By-Law 1999 (asamended). These penalties may be imposed in cases where any significant portion of my submittedwork has been copied without proper acknowledgment from other sources, including published works,the Internet, existing programs, the work of other students, or work previously submitted for otherawards or assessments.I realise that I may be asked to identify those portions of the work contributed by me and required todemonstrate my knowledge of the relevant material by answering oral questions or by undertakingsupplementary work, either written or in the laboratory, in order to arrive at the final assessment mark.I acknowledge that the School of Computer Science, in assessing this assignment, may reproduce itentirely, may provide a copy to another member of faculty, and/or communicate a copy of thisassignment to a plagiarism checking service or in-house computer program, and that a copy of theassignment may be maintained by the service or the School of Computer Science for the purpose offuture plagiarism checking.

admin

Author admin

More posts by admin