The focus of procedural programming is to break down a programming task into a collection of variables, data structures, and subroutines.
In this exercise, we will be dealing with the california covid cases. You are given some records: the date and the number of cumulative cases upto that date in chronological order.
We want to find the average daily growth rate.
Input
Input starts with an integer n (2 ≤ n ≤ 500) denoting the number of records.
Each of the n lines will contain a date and the total number of cases seen so far separated by a single space. Assume that the dates are chronological and from the start date to the end, all the dates will be included.
Output
Print one floating point number denoting the average daily growth rate. Next, print the growth rate group based on the following:
- < 3%
- 3% to 5%
- 5% to 10%
- > 10%
Sample
Sample Input | Sample Output |
---|---|
10 2020-03-04 53 2020-03-05 53 2020-03-06 60 2020-03-07 69 2020-03-08 88 2020-03-09 114 2020-03-10 133 2020-03-11 157 2020-03-12 202 2020-03-13 202 | Average Growth Rate: 16.52% Growth Bucket: > 10% |
Notes
Daily growth rate is computed using the following function:
$$ \sum_{i=1}^{n-1} \frac{(cases_{date_{i+1}} - cases_{date_i}) * 100}{cases_{date_i}} / (n - 1) $$