ECE1016 Computer and Program Design
Take Home Assignment
Trimester 1, 2018: 2024 – Write My Essay For Me | Essay Writing Service For Your Papers Online/19
Group Members:
No. Name Student ID
Majoring
(CE/EE/LE/MCE/
ME/NE/OPE/TE)
Lecture
Section
1.
2.
Write a cash register machine in C that does the following:
a) Display a menu as shown in Figure Q1. Continuously prompt the user to enter the ITEM
CODE until 0 is entered to quit. Be sure to check that the ITEM CODE is always between 1
and 2.
WELCOME TO RESTAURANT MAC C – Main Menu
[1] Add new food items
[2] Take order
Enter ITEM CODE (0 to Quit) :
Figure Q1 – Main Menu
b) If the user enter option 1 in the main menu, continuously prompt the user to enter new
food item repeatedly as shown in Figure Q2. This new input will be appended to an
existing text file, namely Food.txt and displayed on the screen as shown in Figure Q2.
WELCOME TO RESTAURANT MAC C – Add Menu
ITEM CODE DESCRIPTION PRICE (RM)
1 BigM 10.40
2 Cheeseburger 9.45
Enter description (0 to Main Menu) : FriedChicken
Enter price (RM) : 10.50
3 FriedChicken 10.50
Enter ITEM CODE (0 to Main Menu) :FrenchFries
Enter price (RM) : 2.50
4 FrenchFries 2.50
Enter ITEM CODE (0 to Main Menu) :0
Figure Q2 – Add Menu
c) Sample of the input file, Food.txt, is shown in Figure Q3. If the user enter option 2 in the
main menu, menu as shown in Figure Q4 will be displayed.
1 BigM 10.40
2 Cheeseburger 9.45
3 FriedChicken 10.50
4 FrenchFries 2.50
Figure Q3 – Sample of the input file, Food.txt
Existing data in ‘Food.txt’
Appended data in ‘Food.txt’
d) Continuously prompt the user to enter the ITEM CODE until 0 is entered to quit (calculate
the discount, prompt for cash and printing invoice. If ITEM CODE equal to 100, it will go
back to Main Menu.
e) Prompt the user to enter the amount of discount in percentage.
f) Print out an invoice on screen as shown in Figure Q4. The invoice should calculate the
following:
i. Subtotal of all items bought before discount
ii. Amount of discount
iii. Total of all items bought after discount
iv. Prompt the user to enter cash given by buyer
v. If cash given by buyer is less than grand total, prompt again.
vi. Calculate the change.
g) The final invoice will be printed continuosly in a text file, namely Invoice.txt as shown in
Figure Q5.
h) After printing out the invoice, the program should go back to the Take Order menu.
WELCOME TO RESTAURANT MAC C – Take Order
ITEM CODE DESCRIPTION PRICE (RM)
1 BigM 10.40
2 Cheeseburger 9.45
3 FriedChicken 10.50
4 FrenchFries 2.50
Enter ITEM CODE (0 to Quit, 100 for Main Menu) : 1
Enter ITEM CODE (0 to Quit, 100 for Main Menu) : 0
Enter Discount (%) : 10
INVOICE RESTAURANT MAC C
——————————————————————–
ITEM CODE DESCRIPTION PRICE (RM) QUANTITY TOTAL (RM)
1 Big M 10.40 1 10.40
—————————————
Subtotal before Discount 10.40
Discount (10%) – 1.04
—————————————
TOTAL 9.36
CASH TENDERED : 10
CHANGE : 0.64
PRINTING OUT RECEIPT …
ITEM CODE DESCRIPTION PRICE (RM)
1 Big M 10.40
2 Cheeseburger 9.45
3 FriedChicken 10.50
4 FrenchFries 2.50
Enter ITEM CODE (0 to Calculate Total, 100 for Main Menu) : -1
ITEM CODE not available. Try again.
Enter ITEM CODE (0 to Calculate Total, 100 for Main Menu) : 5
ITEM CODE not available. Try again.
Enter ITEM CODE (0 to Calculate Total, 100 for Main Menu) : 2
Enter ITEM CODE (0 to Calculate Total, 100 for Main Menu) : 3
Enter ITEM CODE (0 to Calculate Total, 100 for Main Menu) : 2
Enter ITEM CODE (0 to Calculate Total, 100 for Main Menu) : 0
Enter Discount (%) : 0
INVOICE RESTAURANT MAC C
——————————————————————–
ITEM CODE DESCRIPTION PRICE (RM) QUANTITY TOTAL (RM)
2 Cheeseburger 9.45 2 18.90
3 FriedChicken 10.50 1 10.50
—————————————
Subtotal before Discount 29.40
Discount (0%) – 0.00
—————————————
TOTAL 29.40
CASH TENDERED : 40
CHANGE : 10.60
PRINTING OUT RECEIPT …
Figure Q4 – Sample output of program on screen

INVOICE RESTAURANT MAC C
——————————————————————–
ITEM CODE DESCRIPTION PRICE (RM) QUANTITY TOTAL (RM)
1 BigM 10.40 1 10.40
—————————————
Subtotal before Discount 10.40
Discount (10%) – 1.04
—————————————
TOTAL 9.36
CASH TENDERED : 10
CHANGE : 0.64

INVOICE RESTAURANT MAC C
——————————————————————–
ITEM CODE DESCRIPTION PRICE (RM) QUANTITY TOTAL (RM)
2 Cheeseburger 9.45 2 18.90
3 FriedChicken 10.50 1 10.50
—————————————
Subtotal before Discount 29.40
Discount (0%) – 0.00
—————————————
TOTAL 29.40
CASH TENDERED : 40
CHANGE : 10.60
Figure Q5 – Sample output from the text file ‘Invoice.txt’
Appendix 1A
ECE1016 Computer and Program Design
Take Home Assignment
Trimester 1, 2018: 2024 – Write My Essay For Me | Essay Writing Service For Your Papers Online/19
Group Members:
No. Name Student ID
Majoring
(CE/EE/LE/MCE/
ME/NE/OPE/TE)
Task assigned
1.
2.
Appendix 1
A. General instructions
1. You must work in a group of 2 people.
2. You are required to prepare a report (Maximum 10 pages excluding coding) for the assessment.
3. Report specifications: Font size: 12, Font type: Times New Roman, Line spacing: 1.5. Top, Bottom,
Left, Right margins should be 1”. Kindly include page numbers.
4. Please make sure that you use the sample cover page as provided in Appendix 1A.
5. Your report should contain the following sections in the order given below:
Section 1: Introduction (general specification of the program)
Section 2: Program coding
Section 3: Result and discussion
6. For Section 3, you can use screen capture to copy the program output and paste it in your report.
Explain and discuss the output in your report.
B. Submission
1. Each group should have the cover page provided in Appendix 1A.
2. You must submit the hardcopy of the report. (Each student submit a report)
3. Submission deadline: 28-Sept-2018: 2024 – Write My Essay For Me | Essay Writing Service For Your Papers Online, before 4.30pm.
4. No late submissions. Any late submission will automatically receive 0 marks for all group
members.
5. Submit the HARDCOPY report to Dr. Hezerul Abdul Karim (BR2032) or my pegion
hole.
6. Submission link of source code will be announced later in MMLS.
C. Assessment
1. Grading of the report will be based on the following:
a. Substantive content (how informative it is)
b. Appropriate organization (overall report)
c. Use of allotted report size (within the page limit)
d. Clarity of the report
e. Proper discussion on program’s output.

Published by
Ace Tutors
View all posts