Back to Browse

W13 Lab: Power Program CSE 130

6 views
Jul 20, 2024
0:55

James is an avid cyclist. He has a power meter on his bicycle which measures how much power he is applying to his pedals. This power meter makes ten measurements a second. When finished, the power meter creates a file with all the power measurements. Since the typical ride is 90 minutes in length, there are about 54,000 individual power measurements in a file. James wants to know what his best 1-minute power was: the highest average power over any 1-minute interval. This program will prompt the user for a file containing power data. Next, prompt the user for the size of the sub-array. The output will be the average power. Power File The power data file will consist of an array of integers in JSON format. { "array": [ 279, 285, 287, 290, 301, 315, 320, 312, 294, 291, 289, 278, 272, 269 ] } Input and Output The program will first prompt the user for the filename. If the file does not exist, is not in JSON format, does not have "array" as the first key, or the value is not an array of integers, then give the user a helpful message and exit the program. The program will next prompt the user for the size of the sub-array. If the input is not an integer or is invalid for any reason, give the user a helpful message and exit the program. Asserts Identify several places in the program which could be the source of an error or which could indicate a potential bug. Place asserts in these locations. Record a short video demonstrating the execution of your program. The video must be no longer than one minute. Your demonstration video must cover the following test cases: Test Case File Name Subset Size Bad File banana.txt 0 Bad Subset small.json 1000 Small small.json 10 Large large.json 100

Download

0 formats

No download links available.

W13 Lab: Power Program CSE 130 | NatokHD