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作業(yè)代做、Software Systems作業(yè)代做葛圃、代寫C++語(yǔ)言作業(yè)千扔、C/C++程序設(shè)計(jì)作業(yè)調(diào)試 代做 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轉(zhuǎn)自:http://www.6daixie.com/contents/13/4975.html
講解:COMP-206蹦锋、Software Systems、C++欧芽、C/C++R|SPSS
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門鹤树,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人逊朽,你說(shuō)我怎么就攤上這事罕伯。” “怎么了叽讳?”我有些...
- 文/不壞的土叔 我叫張陵追他,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我岛蚤,道長(zhǎng)邑狸,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任涤妒,我火速辦了婚禮单雾,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘届腐。我一直安慰自己铁坎,他們只是感情好,可當(dāng)我...
- 文/花漫 我一把揭開白布犁苏。 她就那樣靜靜地躺著硬萍,像睡著了一般。 火紅的嫁衣襯著肌膚如雪围详。 梳的紋絲不亂的頭發(fā)上朴乖,一...
- 那天,我揣著相機(jī)與錄音助赞,去河邊找鬼买羞。 笑死,一個(gè)胖子當(dāng)著我的面吹牛雹食,可吹牛的內(nèi)容都是我干的畜普。 我是一名探鬼主播,決...
- 文/蒼蘭香墨 我猛地睜開眼群叶,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼吃挑!你這毒婦竟也來(lái)了钝荡?” 一聲冷哼從身側(cè)響起,我...
- 序言:老撾萬(wàn)榮一對(duì)情侶失蹤舶衬,失蹤者是張志新(化名)和其女友劉穎埠通,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體逛犹,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡端辱,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了虽画。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片舞蔽。...
- 正文 年R本政府宣布做祝,位于F島的核電站,受9級(jí)特大地震影響鸡岗,放射性物質(zhì)發(fā)生泄漏混槐。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一轩性、第九天 我趴在偏房一處隱蔽的房頂上張望声登。 院中可真熱鬧,春花似錦揣苏、人聲如沸悯嗓。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)脯厨。三九已至,卻和暖如春坑质,著一層夾襖步出監(jiān)牢的瞬間合武,已是汗流浹背。 一陣腳步聲響...
- 正文 我出身青樓吃沪,卻偏偏與公主長(zhǎng)得像汤善,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- By clicking to agree to this Schedule 2, which is hereby ...
- 本文轉(zhuǎn)載自知乎 作者:季子烏 筆記版權(quán)歸筆記作者所有 其中英文語(yǔ)句取自:英語(yǔ)流利說(shuō)-懂你英語(yǔ) ——————————...
- 春運(yùn)提前來(lái)了 早晨红淡,從鄭州乘上Z291次火車出差卸伞,來(lái)到所在車廂,發(fā)現(xiàn)車廂行李架上堆滿大包小包锉屈。據(jù)同車廂從新疆烏魯木...
- 總感覺自己的一天做的事太少,每天都有一堆順延的事情垮耳,看似無(wú)關(guān)緊要颈渊,可又舍不得忘記,比如這段文字终佛。 昨天上午徐老師來(lái)...
- import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [...