University of Central Lancashire
Department of Technology
Module EL1311 Software Development
Assignment 2014/2015: Vend
Aim
This assignment is designed to assess your ability to develop a modular program to meet a simple requirement.
Date of Publication
This assignment was published on Friday January 23, 2015.
Submission
This assignment is to be completed and submitted with a completed Assignment Submission Form to me, qingnie, by April 2, 2015.
Background
This assignment is to complete a simple simulation of a vending machine. The program operates on the command-line (e.g. Windows XP console). A screen shot of the final program operation is shown below.
The simulation is called vend. The executable file is called vend.exe. The operation of vend.exe is as follows:
The contents of the vending machine are read at run-time from a price list file, pricelist.txt. The format of pricelist.txt is as follows:
Price Name
Price Name
...
Price Name
0
Here, Price
is the price of an item in the machine, in pence, and Name
is its name. Price
is an integer number. Name
is a string. The name can contain up to 19 characters, including spaces. There can be up to 10 items in the file. If there are fewer than 10 items, the end of the file is indicated by the value Price
field.
The program writes a menu on the screen, listing each item and a price, and prompts for a selection. The user makes a selection by entering the appropriate menu number (0..9). If there are fewer than 10 items in the vending machine, the menu restricts the choice appropriately. To leave the menu, the user must press the CTRL-C
combination on the keyboard.
Once the selection has been made, the program prompts the user to enter the correct price for the item chosen. The user enters "coins" by typing their value in pence at the keyboard. Coins to the value of 10p, 5p, 2p and 1p only are accepted. Other coins are rejected. The program determines the total price entered; once this exceeds the price for the item, the money is accepted and the item is released.
Notice that the program operates on an infinite loop - each time a choice is made, the menu and prompt are displayed again.
Your assignment is to write a program using c++ so that the program performs as shown in the screen shot.
Requirements
1. Your program should perform as shown in the screen shot.
2. Write a function GetItemInfo to get the price & name of each item from the price list file. The prototype for GetItemInfo can be this :
void GetItemInfo(char *file, int price[ ],string itemname[ ],int maxitemnum );
3. Write a function AcceptMoney to accept money from the user. The prototype for AcceptMoney is
void AcceptMoney(int price);
Also note that your code is not required to cope with invalid data types - for example, you can assume that the user will not enter a character when prompted to enter a number. Your program is allowed to fail under those circumstances. It is not required to be "robust". Robust IO will be a future topic in this module. Your program must, however, cope with invalid data values - for example, an invalid coin denomination.
The source code for the program shall be contained in a file called vend.cpp.
You must write your program in VC++6.0 and create an executable which will run on the University computer.
You must also document your program in a report containing:
- A complete listing of your source code file, vend.cpp.
- A description of the process you went through in creating your executable code
- Write a description of the following C++ language features used in function GetItemInfo(char *file, int price[ ],string itemname[ ], int maxitemnum );.
**File IO.
**Pass by value and pass by reference.
- Example results from your program, demonstrating that the program requirements have been met. Do not use the same examples as those given in the screen shot shown above. Illustrate your results either by textual copy and paste from the console window into your report, or by copying and pasting an image of the console window (use Alt|Print Screen to capture an image of the active window).
Deliver the following items to qingnie by the specified submission date:
- Word-processed documentation.
- A 3½" floppy disc, formatted for reading on Windows XP, containing the source code for your programs in a file called vend.cpp and corresponding executable code in a file called vend.exe.
- Deliver the following items to qingnie@bit.edu.cn
A zip file, named as IDNum_Name.zip (example:1_Wanghai.zip).
The zip file contained:
l Word-processed assignment report
l software ( source code +executable file)
Assessment Criteria
This assignment is worth 33% of the marks overall for this module. Marks will be allocated in accordance with the marking scheme given below. Submissions meeting the criteria given for model answers will receive full marks for the corresponding component. Submissions meeting the criteria given for threshold answers will receive 40% of the marks available for the corresponding component.
Component | Weight | Model answer | Threshold answer |
Process description | 20 | Complete and accurate description of the tools used and process followed. | Largely accurate description of the process undergone. |
Program correctness | 30 | Correct implementation of all required program modifications. | Working program with working versions of functions GetItemInfo and AcceptMoney. |
Source code style | 15 | Style guidelines and function definition checklist followed in every respect. | Program layout satisfactory throughout. |
File IO description | 15 | Complete and thorough description of all file IO features used in function GetItemInfo | Accurate description of the main file IO features used in function GetItemInfo. |
Pass by value/pass by reference description | 20 | Thorough explanation of the use of PBV and PBR in function GetItemInfo. | Accurate identification of arguments passed by value and by reference to function GetItemInfo. |
Up to 20 marks may be deducted from your final score for poor presentation. See the following Notes to find out how not to throw marks away like that.
Notes
- This assignment must be all your own work. There are strict penalties for plagiarism and collusion (Academic Regulations G10.3 and Appendix 10 refer). You are liable to be awarded 0% for this assignment if I am not satisfied that your submission is all your own work. You may be interviewed to determine authorship before your marks are determined. You must sign the declaration of authorship on the Assignment Submission Form. Your submission will not be marked unless you do so, and you may incur consequential lateness penalties.
- There are also strict penalties for late submission. If your submission is between one minute and two weeks late, it will be marked but the maximum mark awarded will be 40%. If your submission is two weeks and one minute late, or later, it will not be marked and you will be awarded 0% for this assignment. So don't be late. Start work early, so that you don't have to do it all in a rush at the last minute.
- Clarity of expression in written work is very important - in your studies as in professional life. Structure your report according to the specified documentation requirements. Make sure that your report is complete, but avoid unnecessary material. You must strike a balance between comprehensiveness and conciseness. Use my guidance on the length of my model answer to help you assess the length of your submission for this assignment. Take care to check your speling and, grammar. Make sure that your source code listing (in your report) and your source code file (on your disc) are consistent with each other.
- The manner in which you present your submission is also very important. Your report must be word-processed and presented neatly. Ensure that the pages are securely bound, but not so securely that they can't easily be removed for photocopying (copies of a representative sample of your reports will be retained for quality assurance purposes). Use a "Duraclip" or similar binder. Make sure that each page is marked with your name, the date of completion, the page number, and the total number of pages submitted. Make sure that the front page of your report has this information displayed prominently along with the module name and number and assignment title. Put your name on the floppy disc. Submit your report, the disc and a completed Assignment Submission Form together in a a transparent Snopake "PolyFile" or similar document wallet.
Appendix A: A example of pricelist.txt
pricelist.txt:
40 Mars Bar
40 Toffee Crisp
30 Kit Kat
25 Toblerone
40 Bounty
50 Topic
0