Pineapples have become a major crop in Bulgaria over the last 80 years. The Bulgarian agricultural minister, Mr. Tapak Glupak, thinks that pineapple farming is one of the country's growth industries.
Bulgarian pineapple farmer, 1957
Bulgaria wants to become a member of the International Pineapple Standards, Marketing, Trade, Safety, Inspection and Regulation Commission (IPSMTSIRC), also known as PineComm. PineComm regulations state that pineapples should be between 8% and 11% sugar by weight, although some variance is permitted. Minister Glupak is concerned that Bulgarian pineapples might be too sour or sweet to meet these standards.
Preslav is an analyst for the agriculture ministry. Here's his office in Sofia:
Minister Glupak has asked Preslav to report on the sugar content situation. Preslav has collected pineapples throughout Bulgaria, and had them analyzed by the ministry's science lab. They have given him an Excel worksheet with the results.
Bulgaria's biggest pineapple, 2005
Write a program to analyze the data. Download the starting worksheet, and add your own code. It looks like this:
So, the first pineapple Preslav collected, from a farm in Montana, weighed 1,426 grams, of which 119 grams was sugar. The second pineapple was from a farm in Sofia. The province, not the city. It weighed 1,361 grams, of which 132 grams was sugar.
Your program should:
- Calculate the sugar % for each pineapple.
- Highlight sugar s that are outside PineComm's specification, that is, less than 8 or more than 11%.
- Show the total number of pineapples analyzed.
- Show the number of pineapples that are outside PineComm's spec.
- Show the % of pineapples that are outside spec.
- Show the average weight of all pineapples.
- Show the average sugar weight of all pineapples.
- Show the average sugar % of all pineapples.
Here's some sample output:
- Make sure that Preslav could easily add more data, and rerun the analysis, without changing the code.
- Assume that all of the data is correct, that is, there are no input errors.
- So you not have to round your output.
- You do not have to use subs, though you can if you want.
Hint: each time through the loop, your code should read data for one pineapple, process it, and output the pineapple's sugar %.
Upload your solution.
(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)