thoughtworks面试题

undertones1985 2009-11-18 11:37:51
今天去面试,公司给我用email发了到题,我不太会做,大家一起看看吧。(要求用C++是实现)

PROBLEM TWO: SALES TAXES



Basic sales tax is applicable at a rate of 10% on all goods, except books, food, and medical products that are exempt. Import duty is an additional sales tax applicable on all imported goods at a rate of 5%, with no exemptions.



When I purchase items I receive a receipt which lists the name of all the items and their price (including tax), finishing with the total cost of the items, and the total amounts of sales taxes paid. The rounding rules for sales tax are that for a tax rate of n%, a shelf price of p contains (np/100 rounded up to the nearest 0.05) amount of sales tax.



Write an application that prints out the receipt details for these shopping baskets...

INPUT:



Input 1:

1 book at 12.49

1 music CD at 14.99

1 chocolate bar at 0.85



Input 2:

1 imported box of chocolates at 10.00

1 imported bottle of perfume at 47.50



Input 3:

1 imported bottle of perfume at 27.99

1 bottle of perfume at 18.99

1 packet of headache pills at 9.75

1 box of imported chocolates at 11.25



OUTPUT



Output 1:

1 book : 12.49

1 music CD: 16.49

1 chocolate bar: 0.85

Sales Taxes: 1.50

Total: 29.83



Output 2:

1 imported box of chocolates: 10.50

1 imported bottle of perfume: 54.65

Sales Taxes: 7.65

Total: 65.15



Output 3:

1 imported bottle of perfume: 32.19

1 bottle of perfume: 20.89

1 packet of headache pills: 9.75

1 imported box of chocolates: 11.85

Sales Taxes: 6.70

Total: 74.68

==========
...全文
3258 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
kevingu321 2012-04-27
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 的回复:]

对于第三个里面的 1 box of imported chocolates at 11.25 为什么我算出的Tax是0.55而不是0.6
11.25*0.05 = 0.5625 按照题中说的算法,Round下是0.55……加出来是 1180 而不是结果中的 11.85
[/Quote]

是11.85,而且就算按你的算法应该是11.81
kevingu321 2012-04-27
  • 打赏
  • 举报
回复
对的

里面有句话,你们没找到


我也收到邮件了但是没通过...
ThoughtWorks考的是面向对象,纠结字符串你就错了
风影极光 2012-04-07
  • 打赏
  • 举报
回复
且不评论这道题怎么设计,首先给的测试数据就有问题,比如
1 imported bottle of perfume at 47.50,输出应为54.63;
1 box of imported chocolates at 11.25,输出应为11.81.
应该不对吧!
xdx2ct1314 2012-03-02
  • 打赏
  • 举报
回复
你电话技术面试了吗?呵呵
darklzr 2011-05-28
  • 打赏
  • 举报
回复
对于第三个里面的 1 box of imported chocolates at 11.25 为什么我算出的Tax是0.55而不是0.6
11.25*0.05 = 0.5625 按照题中说的算法,Round下是0.55……加出来是 1180 而不是结果中的 11.85
cattycat 2009-11-18
  • 打赏
  • 举报
回复
看来计算还算简单,主要是处理字符串了。像4楼的发现输入的格式读取物品和价格。
gelu1040 2009-11-18
  • 打赏
  • 举报
回复
只是计算商品的价格和价格构成(原价+tax+Import duty )
la_feng 2009-11-18
  • 打赏
  • 举报
回复
你这个主要是能看懂英文就不难
Jinhao 2009-11-18
  • 打赏
  • 举报
回复
一项:
数字 物品 at 价格 换行

物品:
任意字符(空格 任意字符)*

其实还是很简单的嘛,这还像个面试题,不像某些公司搞得这么装逼..问什么加油站有多少,汽车多少之类的.搞得像是脑筋急转弯
sj13426074890 2009-11-18
  • 打赏
  • 举报
回复
mark
rlxtime 2009-11-18
  • 打赏
  • 举报
回复
唉! 真不知道现在的公司想要什么样的人!
Jinhao 2009-11-18
  • 打赏
  • 举报
回复
把文本tokenize成number whitespace what_good whitespace at whitespace price
然后建立 物品 和 种类 的table,剩余的就容易了
JENNEY123123 2009-11-18
  • 打赏
  • 举报
回复
这不是很简单吗???
do_fork 2009-11-18
  • 打赏
  • 举报
回复
像是大一新生里选拔ICPC队员的题

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧