Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2338074
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:07:44

The idea is that the user first enters how much money he/she has saved and is ready to spend. The computer will then search for possible items from our list and provide the user with a revised list of items that he/she can afford.
The complete list of shopping items is:

1. Running shoes.
$250 for Extra Fast Running shoes
$200 for Good Running shoes
$50 for NoName Shoes

2. Winter Jacket:
Extra Warm $300
Water proof and thermal coating $250
Nylon $40

3. School Back-pack:
Leather "Cool" Logo $40
NoName $20

4. "Birthday" card for a friend
Musical $5 Normal $1
The prices and brands are fictional for the purpose of this exercise but these prices do not include the taxes. (We pay 15% tax here!). So when you calculate if an item is affordable or not, make sure you account for the tax overhead.

Program logic:
1. Ask the user for how much money he/she is willing to spend.
2. List all affordable items.
5. If none of the items are affordable then display an appropriate message (be creative).
Tip: Inflate the prices by 15% (tax) in order to accurately predict if an item is affordable or not.

Example:

_-=== Shopping Calculator ===-_

How much money you want to spend? 0
Sorry, you need to have money to spend... try again
How much money you want to spend? 200
Possible Shopping Items:
1. NoName Running Shoes
2. Nylon Winter Jacket
3. Leather "Cool" Logo School Back-pack
4. NoName School Back-pack
5. Musical Birthday Card
6. Normal Birthday Card

Do you want to try again? y

How much money you want to spend? 3
Possible Shopping Items:
1. Normal Birthday Card

Do you want to try again? n
Ok, have fun shopping. Bye.

--- End of Summary ---


--------------------next---------------------

阅读(1517) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~