Reference no: EM13865218
Program (console)
The company is very interested in making a comparison of the reliability of the different models it has installed.
Its models are simply named model A, model B, etc. For each model there are many separate instal- lations, identified by sequence number of 8 digits. Each elevator is uniquely identified by a serial number that starts with the model letter and ends with its sequence number.
Files have been created that aggregate the logs of many elevators:
• Each line starts with the serial number of an elevator.
• The rest of line is as per a log for one elevator:
- A U labels a time as a tup, or a D labels a time as a tdown, followed by the time in seconds since the elevator was first put into service.
- The first line for each elavator will always indicate tup at 0 seconds.
- The last line for each elavator is usually also a tup, though it is possible that the log has been uploaded while the elevator is out of service, and therefore the last line is a tdown.
- A new elevator that has not failed yet may have one line for it.
• The file has been sorted by serial number and then time.
• Not all models might be represented in the file. The serial numbers might not be sequential.
• A new model might not have suffered any fail- ures yet.
The first 25 lines of file: small.txt
A00000001
|
U
|
0
|
A00000001
|
D
|
37902420
|
A00000001
|
U
|
37926167
|
A00000001
|
D
|
81482848
|
A00000001
|
U
|
81508838
|
A00000001
|
D
|
129373255
|
A00000001
|
U
|
129393392
|
A00000001
|
D
|
172752889
|
A00000001
|
U
|
172793133
|
A00000001
|
D
|
208904424
|
A00000001
|
U
|
208933554
|
A00000001
|
D
|
243425572
|
A00000001
|
U
|
243454010
|
A00000002
|
U
|
0
|
A00000003
|
U
|
0
|
A00000003
|
D
|
67943195
|
A00000003
|
U
|
67966385
|
A00000003
|
D
|
136952512
|
A00000003
|
U
|
136979618
|
A00000003
|
D
|
213738461
|
A00000003
|
U
|
213766673
|
A00000004
|
U
|
0
|
A00000004
|
D
|
23733729
|
A00000004
|
U
|
23772528
|
A00000004
|
D
|
51036894
|
Another data file exists with much more data: big.txt.
Write a program that reports the comparison for all models represented in the data file in a table, reporting: the number of each model installed; the total uptime, the total number of failures, and the overall MTBF.
Example output for these two data files:
$ java AnalyseMany < small.txt
|
model
|
#
|
total uptime (years)
|
total fails
|
MTBF (years)
|
A
|
7
|
23.7
|
17
|
1.39
|
B
|
5
|
10.4
|
12
|
0.87
|
D
|
4
|
17.5
|
14
|
1.25
|
E
|
2
|
---
|
0
|
---
|
$ java AnalyseMany < big.txt
|
model
|
#
|
total uptime (years)
|
total fails
|
MTBF (years)
|
A
|
2150
|
8370.6
|
12601
|
0.66
|
B
|
3113
|
48216.5
|
96360
|
0.50
|
C
|
2842
|
16980.9
|
23590
|
0.72
|
D
|
2075
|
26007.3
|
40786
|
0.64
|
E
|
3078
|
12670.8
|
13341
|
0.95
|
F
|
734
|
15772.3
|
36384
|
0.43
|
G
|
2371
|
3907.1
|
2524
|
1.55
|
H
|
3720
|
48103.1
|
23993
|
2.00
|
I
|
2938
|
28301.9
|
42149
|
0.67
|
J
|
1355
|
7641.2
|
14022
|
0.54
|
$
|
Note how the results are reported when there have been no failures, and that to make the table neat, the format of the numbers has been controlled.