Question: Provide a user interface to look up the CPI values for any year. The program should read a year number from the keyboard and print

Provide a user interface to look up the CPI values for any year. The program should read a year number from the keyboard and print out the list of CPI values for that year. After that, it should print out the average CPI for that year (by computing the average of the reported list).
Enter query: 1950
[23.5,23.5,23.6,23.6,23.7,23.8,24.1,24.3,24.4,24.6,24.7,25.0]24.066666666666666
Enter query: 2000
[168.8,169.8,171.2,171.3,171.5,172.4,172.8,172.8,173.7,174.0,174.1,174.0]172.19999999999996
Enter query:
Enhance the program by allowing the user to specify the list of months they want to see. A valid query may in addition to the year number contain a list of month numbers separated by spaces.
For example, 19501357 requests the data for January, March, May, and July of 1950. If the months are not specified, report full year. The average should be computed only for the reported months.
Enter query: 1950
[23.5,23.5,23.6,23.6,23.7,23.8,24.1,24.3,24.4,24.6,24.7,25.0]24.066666666666666
Enter query: 19501357
[23.5,23.6,23.7,24.1]23.725
Enter query: 195056
[23.7,23.8]23.75
Enter query:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!