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
http://www.cnblogs.com/congzc/archive/2011/07/09/2329941.html