Sie sind auf Seite 1von 2

S2AY2011/12 CS2103 Software Engineering Coding Exercise 1 (CE1) 5%

Submit by : Saturday January 21 in IVLE workbin


Overview: The IT Fair has very much become a part of Singaporean culture. With the annual
SITEX and COMEX events, Singaporeans are not only able to find value bargains for consumer electronic products, they also get to feast their eyes on the latest and greatest technology in the market.

Write a personal budget assistant to help decide the ideal set of products to buy at the IT fair. Objectives: Get started with the project work by refreshing your programming knowledge from previous modules. Align your coding style with the object-oriented paradigm. Get started with some basic tools of the trade.

Task Statement: At the IT Fair, we come up with a shopping list of n kinds of items, 1 through n. Each kind of item i has a price Pi and a satisfaction value Si. Both Pi and Si are non-negative (we do not add something we dislike to our shopping list). Given a budget of B, personal budget assistant has to decide which items to buy to maximize our satisfaction level (the sum of the satisfaction values of items bought) while keeping within our budget B. Note: To simplify things, we either buy 1x of the item or dont buy the item. Task Elaboration: The program should take multiple lines of input in the following format:
[item] [price] [satisfaction value]

Next, the user should be asked for a budget B not larger than the total price of all the items. The output would be a list of items to be bought, the total satisfaction value and the total price of the items. For example the input could be:
Page 1 of 2

4 //n number of items samsung_hdd_1tb 200.00 3 epson_printer 300.00 4 canon_ixus 400.00 5 apple_ipad 500.00 6

Given a B of 500.00, we get output:


Buy: samsung_hdd_1tb for 200.00 epson_printer for 300.00 Satisfaction: 7 Spent: 500.00

Challenge: Suppose that we have not done our research properly and we have multiple items of the same type in our shopping list (e.g. we have both Brand A and Brand B tablets in our shopping list). Improve your application to be able to take in a shopping list with items of the same type.
[item] [price] [satisfaction value] [type]

Your application should be able to generate a list of items to buy which maximizes the satisfaction value under the constraint that you do not buy more than 1 of each item type. Submission: You can code personal budget assistant in Java or C++ or C#. Give filename as PBA-YourMatricNumber Submit source as well as executable in the appropriate folder in IVLE. For example, if you have chosen Java, submit your file in Java_CE1 folder. Grading : Your work will be awarded full marks if it correctly works and is error-free. For other cases partial marks(<= 50%) may be awarded. You will not be penalized for using or not using any specific algorithm. However you are encouraged to use an efficient algorithm. You may briefly describe your approach in comments at the beginning of the code . You are also encouraged to follow good coding practices e.g. using meaningful variable names and avoiding spaghetti code.
Page 2 of 2

Das könnte Ihnen auch gefallen