Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Programming Fundamentals I Sec

Programming Fundamentals I Sec

Computer Science

Programming Fundamentals I Sec. 601 
Lab Assignment #10 Benchmark Data 
Due date: 11/18/20 at 11:59 pm 
Purpose: The lab this week focuses on two-dimensional arrays as well as considers the relationship to one-dimensional arrays. 
Task: Create a project called BenchmarkData FirstName_LastName or Lab1O_FirstName LastName. Remember to include comments summarizing the program. 
1. This program will require writing data to a text file. Include the appropriate import statement in order to achieve this functionality. Additionally, make sure the method header indicates the possibility of throwing an I0Exception. 2. Declare a one-dimensional array that contains the following set of data: 
37, 54. 4, 40, 59, 38, 28, 95, 97. 84. 11, 98, 90, 9, 70, 2, 42, 65, 66. 75, 13, 57, 93. 21. 18, 68, 25, 87. 72. 71, 24, 30, 83, 19. 92. 23, 35, 20, 80, 64, 96, 14, 67. 82. 6. 63, 55, 94, 86, 45. 58. 51, 46. 78. 85, 50, 62, 69, 10. 17. 5, 34, 49, 88, 44, 26, 79, 60, 29, 39, 41, 1, 61, 16, 22, 12, 89, 32, 33. 91. 74, 56, 48, 81, 53. 15. 47, 27, 2, 31, 43, 99. 73. 7. 76, 77, 3, 52, 8, 36 
To provide some context, this data set represents ten sets of benchmark tests to assess the efficiency of computer processors. Each set consists of ten times (in microseconds). 3. To better organize this data, you will declare a two-dimensional array and assign values from the original one-dimensional array to the proper positions. In this case. the first set of ten values is placed into the first inner array. the second set of ten values is placed into the second inner array. and so on. 
In order to move data into the two-dimensional array, you will need a for loop to step through the elements of the one-dimensional array. You will also need to consider the relationship between the index in the one-dimensional array compared to the row and column in the two-dimensional array. 4. Construct an object of the PrintWriter class that will write to a file called "BenchmarkData.txt". An example of the contents of this file is given at the end of the directions. 5. Write a set of column headers into the file. Each column header will specify the time (Time 1, Time 2, etc.). This header can be separated into the String literal "Time" and the numbers 1 through 10. The first header is positioned by specifying a formatted width of 14 for the String. The remaining headers are positioned by specifying a formatted width of 6 for the String. 
6. The remainder of the file's contents will consist of ten rows. Use the two-dimensional array to handle writing data and performing calculations on that data. This will require nested for loops: one for loop for the rows, and one for loop for the columns (specifically, the ten times to be inserted into a row). 7. The start of each row indicates the test for that row (Test 1, Test 2, etc.) and a separator character (I). To properly align the data, the number of the test must have a formatted width of 2. 8. Declare a double variable that will hold the product of the ten times for that row. Initialize this variable to an appropriate starting value. 9. Next, each row lists the ten times associated with that specific test. The first number is positioned by specifying a formatted width of 5. The remaining numbers are positioned by specifying a formatted width of 8. Also, multiply the number currently being written to the file with the product and assign the result back to the product variable. 10. Finally, the geometric mean of those ten times is listed at the end of the row with another separator character preceding it (I). The geometric mean is calculated by multiplying all of the numbers together (completed in steps 8 and 9) and taking the nth-root of that product. In this case, you are multiplying ten numbers together and taking the 10th-root of the number. The root can be calculated by using Math.pow(base, exponent), where the base is the product and the exponent will be a fraction. The geometric mean must be formatted to three decimal places and use a width of 7. 11. Remember to close the file at the end of the program. 
BenchmarkData.t - Notepad File Edit Format View Help 
Time 1 Time 2 Time 3 Time 4 Time 5 Time 6 Time 7 Time 8 Time 9 Time 10 Test 1 37 54 4 40 59 38 28 95 97 84 41.603 Test 2 11 98 90 9 70 2 42 65 66 75 33.251 Test 3 13 57 93 21 18 68 25 87 72 71 42.603 Test 4 24 30 83 19 92 23 35 20 80 64 39.220 Test 5 96 14 67 82 6 63 55 94 86 45 47.282 Test 6 58 51 46 78 85 50 62 69 10 17 44.832 Test 7 5 34 49 88 44 26 79 60 29 39 36.752 Test 8 41 1 61 16 22 12 89 32 33 91 24.865 Test 9 74 56 48 81 53 15 47 27 2 31 31.647 Test 10 43 99 73 7 76 77 3 52 8 36 29.904 
 

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE