School of Computer Science, McGill UniversityCOMP-206 Introduction to Software Systems, Winter 2020Mini Assignment 5: C Programming - Functions and File I/OThis is an individual assignment. You need to solve these questions on your own. Use the discussionforum on Piazza if you have any questions. You can also reach out to the course email address,utilize TA/Instructors office hours as necessary. Late penalty is -5% per day. Even if you are lateonly by a few minutes it will be rounded up to a day. Maximum of 2 late days are allowed.You MUST use mimi.cs.mcgill.ca to create the solution to this assignment. You must not use yourMac command-line, Windows command-line, nor a Linux distro installed locally on your laptop. You can ssh orputty from your laptop to mimi.cs.mcgill.ca, or you can go to the third floor of Trottier and use any of thoselabs to ssh to mimi to complete this assignment. All of your solutions should be composed of commands that arecompilable/executable in mimi.cs.mcgill.ca.Questions in this exercise requires you to turn in one C program. Instructors/TAs upon their discretion may askyou to demonstrate/explain your solution. No points are awarded for commands that do not execute at all or programsthat do not compile in mimi. (Commands/programs that execute/compile, but provide incorrect behavior/outputwill be given partial marks.). All questions are graded proportionally. This means that if 40% of the question iscorrect, you will receive 40% of the grade.Please read through the entire assignment before you start working on it. You can loose up to 3points for not following the instructions.Unless otherwise stated, all the names of the scripts and programs that you write, commands, options, inputarguments, etc. are implied to be case-sensitive.Total Points: 20Ex. 1 — A Banking System ApplicationIn this exercise, you will create a C program, bankapp.c to implement a simple banking application.Your application provides three capabilities: (i) Add an account number, (ii) Make a deposit, (iii) Make a withdrawal.All of your banking data is stored in a CSV file bankdata.csv which has the following format. You can use vi tocreate a sample data file of your own for testing purposes.AC,2023,Jane SmithTX,2023,2020-02-10,1023.34AC,5023,Sally LongTX,2023,2020-02-10,-103.34TX,5023,2020-01-15,78.00As can be seen above, there are two kinds of records in this CSV file. (i) Account records, indicated by AC in the firstfield, followed by a 4 digit account number, followed by the name of the account holder (max 30 characters long).(ii) Then there are transaction records that are indicated by TX in the first field, followed by the account number,transaction date in YYYY-MM-DD format, followed by the amount of money deposited or withdrawn (negative valuesfor the latter).1.Use vi to create a C program source file bankapp.c2.(1 Point) The program should include a comment section at the beginning that describes its purpose (coupleof lines), the author (your name), your department, a small “history” section indicating what changes you didon what date. The code should be properly indented for readability as well as contain any additional commentsrequired to understand the program logic.13.(1 Point) The source code should be compilable by (exactly) using the command gcc -o bankapp bankapp.c4.(1 Point) The compilation step should not issue any warnings.5.(1 Point) All the error messages must be printed to stderr and not stdout.6.(2 Points) Your program’s usage is as follows.To add a new account$ ./bankapp -a ACCTNUM NAMETo make a deposit$ ./bankapp -d ACCTNUM DATE AMOUNTTo make a withdrawl$ ./bankapp -w ACCTNUM DATE AMOUNTAny other attempt must throw a usage error. You may however, chose to ignore the extra argumentspassed to any of the above valid options at your discretion and continue processing. The exit codefor invalid usage of your program should be 1.$ ./bankappError, incorrect usage!-a ACCTNUM NAME-d ACCTNUM DATE AMOUNT-w ACCTNUM DATE AMOUNT$ echo $?1In case the user passed a valid option but did not pass sufficient arguments to process it, provide a morecustomized error message.$ ./bankapp -a 1024Error, incorrect usage!-a ACCTNUM NAME$ echo $?1$ ./bankapp -d 1024 2010-02-12Error, incorrect usage!-d ACCTNUM DATE AMOUNT$ echo $?1$ ./bankapp -w 1024Error, incorrect usage!-w ACCTNUM DATE AMOUNT$ echo $?17.(1 Point) Your program should read the data contentsCOMP-206作业代做、Software Systems作业代做、代写C++语言作业、C/C++程序设计作业调试 代做 from a CSV file, bankdata.csv. It must be present inthe current directory. If the program cannot find it, it must thrown an error and terminate with code 100.$ ./bankapp -a 1024 John SmithError, unable to locate the data file bankdata.csv$ echo $?1008.(2 Points) Your program must allow new accounts to be added. These accounts will be appended to the datafile bankdata.csv.2$ ./bankapp -a 1024 John Doe$ tail -1 bankdata.csvAC,1024,John DoeIf the account number already exists (as indicated by the AC records), then the program should not add it,instead throw an error message to indicate this and terminate with error code 50.$ ./bankapp -a 1024 John DoeError, account number 1024 already exists$ echo $?509.(3 Points) Your program should facilitate deposits to an existing account. A transaction record indicating theamount of money to be deposited is then appended to the data file.$ ./bankapp -d 1024 2020-02-12 334.52$ tail -1 bankdata.csvTX,1024,2020-02-12,334.52If the account does not exist, it should throw an error message and terminate with code 50.$ ./bankapp -d 1025 2020-02-12 334.52Error, account number 1025 does not exists$ echo $?5010.(4 Points) Your program should facilitate withdrawals from an existing account. A transaction record indicatingthe amount of money that is withdrawn is then appended to the data file.$ ./bankapp -w 1024 2020-02-14 20.00$ tail -1 bankdata.csvTX,1024,2020-02-14,-20.00If the account does not exist, it should throw an error message and terminate with code 50.$ ./bankapp -w 1025 2020-02-14 20.00Error, account number 1025 does not exists$ echo $?50If the account does not have enough balance, it should display an error message, and also indicate the currentbalance in the account. Terminate with code 60. You should be able to compute the existing balance on theaccount by adding up all the deposits and withdrawals on the account. Make sure that the amounts you printon the screen has only 2 decimal places.$ ./bankapp -w 1024 2020-02-15 2020.00Error, account number 1024 has only 314.5211.(1 Points) Remember to terminate the successful execution of your program with code 0.12.(2 Point) Your program must not crash because the data file is empty (or at any other situation). Instead itshould do the proper processing according to the scenarios already described earlier. (i.e, add a new account,let the user know the account does not exist for a transaction, etc.).13.(1 Point) Your program should include some function definitions of your own. At a minimum, you should haveone function per operator. You are free to have additional functions in your program.** Important ** If your program “hangs” / is stuck while executing it through the tester script and requires TAsto interrupt it, you will loose 4 points. If your program causes corruption of the data file for any of the test cases,you will loose 4 points.3WHAT TO HAND INTurn in the C program source code bankapp.c named properly. You do not have to zip the file. The file must beuploaded to mycourses. DO NOT turn in the executable bankapp or your testing CSV file bankdata.csv. TAs willcompile your C program on their own as indicated in the problem descriptions above.MISC. INFORMATIONThere is a tester script mini5tester.sh that is provided with the assignment that you can use to test how yourprogram is behaving. TAs will be using the exact same tester script to grade your assignment.$ ./mini5tester.shHowever, it is recommended that when you start writing your program, test it yourself first with the aboveexamples. Make a test case for each scenario by creating your own bankdata.csv file that has the format mentionedabove. Once you are fairly confident that your program is working, you can test it using the tester script.You can compare the output produced by running the mini tester on your C program to that produced by themini tester on the solution programs which is given in mini5tester.out.txt.FOOD FOR THOUGHT!The following discussion is meant to encourage you to search independently for creative and optimal ways to performrudimentary tasks with less effort and/or make your program robust and sophisticated. It does not impact the pointsthat you can achieve in the above questions.• As we know, I/O is a slow process and can be costly if you have very large files. Can your program makedecisions in certain scenarios (both fail cases and successful cases) without having to read all of the data file?4转自:http://www.6daixie.com/contents/13/4975.html
讲解:COMP-206、Software Systems、C++、C/C++R|SPSS
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- By clicking to agree to this Schedule 2, which is hereby ...
- 本文转载自知乎 作者:季子乌 笔记版权归笔记作者所有 其中英文语句取自:英语流利说-懂你英语 ——————————...
- import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [...