Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Virtuous Crisis Undertakings ( VCU ) is a disaster relief organization that helps distribute supplies to disaster ridden areas. They are currently looking for cargo

Virtuous Crisis Undertakings (VCU) is a disaster relief organization that helps distribute supplies to disaster ridden areas. They are currently looking for cargo planes that can replace their current fleet while maintaining their current running costs. You will write a program that will accept, at the command line, two Strings, one containing various plane efficiency metrics, and another containing the values of these metrics A sample of the two strings are below:
mpg,volume-capacity,weight-capacity,maintenance-costs,landing-distance,lifespan
58.40,700.44,83.66,2500.5,2.36,25.67<>40.41,979.58,77.17,4504.85,2.83,29.86<>89.97,720.96,67.07,2041.11,1.69,17.29<>58.97,518.94,32.95,3608.99,3.20,44.46<>82.92,601.68,92.00,7385.93,1.77,19.90<>111.23,684.00,83.92,3808.82,2.31,25.55
The aircraft efficiency metrics in the first string are separated by a "," symbol. The values found in the second string are separated into a two-dimensional grid by the "<>" symbol and separated into each column by a "," symbol.
The first method is the getMetrics() method. This method takes in a String of aircraft efficiency metrics and returns a one-dimensional String array containing the list of elements. You can use the String method .split(",") to split your string based on the "," character separating the categories. Here is the method header.
public static String[] getMetrics(String efficiencyMetrics){
//Your code here
}
The second method is the getPlaneData() method. This method takes in a String of plane data and returns a two-dimensional double array containing the efficiency metric values for each metric for each plane from the string passed in. Again, you can use the String method .split("String") to split your string based on the char character you specify. You will need to split this string on the "," and "<>" symbols. Here is the method header.
public static double[][] getPlaneData(String
planes){
//Your code here
}
Here is an example of the two arrays that are created from the two methods. Note the two-dimensional array will just contain the plane metric values. This is just an example of the data that might be used to test your code. The efficiency metrics and their order will not change. However, the plane data values will change, but will always be numerically labeled starting with the number 1.
mpg
volume-capacity
weight-capacity
maintenance-costs
landing-distance
lifespan
mpg
volume-capacity
weight-capacity
maintenance-costs
landing-distance
lifespan
Plane 1
58.4
700.44
83.66
2500.5
2.36
25.67
Plane 2
40.41
979.58
77.17
4504.85
2.83
29.86
Plane 3
89.97
720.96
67.07
2041.11
1.69
17.29
Plane 4
58.97
518.94
32.95
3608.99
3.2
44.46
Plane 5
82.92
601.68
92
7385.93
1.77
19.9
Plane 6
111.23
684
83.92
3808.82
2.31
25.55
The third method is the findPlaneViability() method. This method takes in a 2D double array of efficiency metrics. It will search each plane for the ones that achieve adequate viability. The formula for running cost is as follows:
viability =mpg*100+ maintenanceCosts2lifespanvolumeCapacity700weightCapacity832.4-landingDistance2.4+0.5
The criteria value that needs to be attained is: 83. If this criteria value is attained or surpassed, then the plane number is returned in an int array. Since not all planes may meet the criteria, the array returned should be resized so that it only contains the values that meet the criteria with no extra data. Using the data above as an example, if rows 1,3,5, and 6 all have a viability score greater than 83, so findPlaneViability would return the array {1,3,5,6} and no other extra values (probably need to double check these calculations)
public static int[] findPlaneViability(double [][] planes){
//Your code here
}
The fourth method is the searchHighestPlaneMetric() method. This method takes in a 2D double array of plane efficiency metric values, a String array of metrics, and a plane number. (Remember a plane number is one off from its index in the array) It will search the given plane for its two highest value metrics and will return a string containing their metrics in the order of highest metric first, second highest metric second with spaces and the word and connecting them. i.e.mpg and volume-capacity
public static String searchHighestMetric(double [][]
planes, String[] metrics, int planeNumber){
//Your code here
}
The fifth method is the searchHighestPlane() method. This method takes in a 2D double array of plane efficiency metric values, a String array of metrics, and a single efficiency metric name. It will search for and return the plane number of the plane which contains the highest efficiency metric value for the given efficiency metric.
public static int searchHighestPlane(double [][]
planes, String[] metrics, String metric){
//Your code here
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions