编程介的小学生 2016-12-24 07:02 采纳率: 20.5%
浏览 788
已采纳

Take Your Vitamins

Description

Write a program to help prepare these nutritional labels by computing that percentage from the information on the amount present in one serving and the amount constituting the minimum daily requirement.
Input

Input consists of one or more lines, each of the form:

A U R V

where A is the amount of a vitamin/mineral present in one serving of the food product, U is the units in which A is measured, R is the minimum daily requirement for that vitamin/mineral, measured in the same units as A , and V is the name of that vitamin/mineral. A and R will be floating point numbers. U will be a string of alphabetic characters with no embedded spaces. V will be a string of characters, possibly including spaces. A , U , R , and V will be separated from one another by exactly one space, and V is terminated by the end of the input line. End of the input is signaled by a line in which A is negative.
Output

For each line of input data, your program should determine the percentage of the recommended daily requirement being provided for that vitamin/mineral. If it is at least 1% , your program should print a line of the form

V A U P %

where V , A , and U are the quantities from the input, and P is the percentage of the minimum daily requirement represented by the amount A .

V should be printed left-justified on the line. A should be printed with 1 digit precision, and P with zero digits precision. V , A , U , and P should be separated by one space each.

After the last such line, your program should print a line stating

Provides no significant amount of:

followed by a list of the names of all vitamins/minerals which are provided as less than 1% of the minimum daily requirement. These should be printed one name per line, in the order they occurred within the input.
Sample Input

3500.0 iu 5000.0 Vitamin A
60.0 mg 60.0 Vitamin C
0.15 g 25.0 Fiber
109. mg 990. Phosphorus
0.0 mg 1000.0 Calcium
25.0 mg 20.0 Niacin
-1.0 x 0.0 x
Sample Output

Vitamin A 3500.0 iu 70%
Vitamin C 60.0 mg 100%
Phosphorus 109.0 mg 11%
Niacin 25.0 mg 125%
Provides no significant amount of:
Fiber
Calcium

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-12-24 16:21
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?