Question: Martians wants a program to help them analyze the soil on Mars. They want to determine the best areas to grow crops. Your program


Martians wants a program to help them analyze the soil on Mars. They want to determine the best areas to grow crops. Your program will help them by performing soil analysis. The program will accept two Strings of data from the command line, one containing various soil composition elements and another containing measurements of the respective elements within a set of soil samples. Here's a sample of the two Strings: carbon-dioxide,magnesium, sodium, potassium chloride,water 8.3,4.5,6.7,2.3,12.5,4.5 3.9,1.8,34.7.23.5, 1.2,14.3 6.7.7.4,1.5,18.4,7.2,23.7 23.4,5. 6,2.9,18.5,39.5,18.2 15.4.5.3,27.4,9.8,3.8,27.4 The element names in the first string are separated by commas. The values in the second string are separated into rows, marked by the " " character combination, and columns, separated by commas. Each row corresponds to one sample, and the columns correspond to the elements listed in the first string. Your program will be tested with other datasets in addition to this one. MoonSamples.java will contain these methods. void main(String[] args) String[] getElements (String inputElementString) double[][] getSamples (String inputSamplesString) int[] searchForLife (double [][] samples) String searchHighestElements (double [1] samples, String[] elements, int sampleNum) int searchHighest Sample (double [1] samples, String[] elements, String element) main method The main method will do the following: Get the two Strings from the command line. You can assume that the command-line arguments are valid. Pass the first String to getElements() and store the result Pass the second String to getSamples() and store the result Call searchForLife(), passing in the result of getSamples(), and print the result Call searchHighestElements(), passing in the results of getSamples() and getElements(), and a sample number, then print the result Call searchHighestSample(), passing in the results of getSamples() and getElements(). and an element name, then print the result This is a sample output from the main method: The samples that contain life are: 45 The highest elements for sample 1 are chloride and carbon-dioxide The sample with the highest value of the element water is 5 The other methods public static String() getElements (String inputElementString) This method takes in a list of elements in the format described above and returns a String array containing the individual element names. There may be any number of elements. public static double () () getSamples (String inputSamplesString) This method takes in a String of sample values in the format described above and returns a two- dimensional double array containing the values. Here is an example of the arrays created by the first two methods, based on the sample data shown above. carbon dioxide magnesium sodium potassium chloride water carbon dioxide magnesium sodium potassium chloride water Sample 1 8.3 4.5 6.7 2.3 12.5 4.5 2 3.9 1.8 34.7 23.5 1.2 14.3 3 6.7 7.4 1.5 18.4 7.2 23.7 4 23.4 5.6 2.9 18.5 39.5 18.2 5 15.4 5.3 27.4 9.8 3.8 27.4 public static int[] searchForLife (double ( ) ( ) samples) This method takes in a 2D double array of sample values. It will search all samples for the ones that could support life. The criterion for supporting life is based on this formula: (8 carbon dioxide) + (2 magnesium) + sodium + (4 potassium) + chloride (5 water) The minimum value for life is 300. If this value is attained or surpassed for a sample, then the sample number (1-based) is included in the array that is returned. For example, If the first row of data attains the score of 300 or more, then the number 1 will be inserted into the first position in the int array. Since not all samples may meet the criteria, the array that is returned should be sized so that it contains only the sample numbers that meet the criterion, with no extra data. This method assumes that there are six columns in the array, and that the samples correspond respectively to the six elements listed in the formula. public static String searchHighestElements (double ( ) (] samples, String() elements, int sampleNum) This method will take in a 2D double array of sample values, a String array of element names, and the number (1-based) of a sample to search. It will return a string containing the names of the two elements that are found in the highest amounts for that sample, in the order of highest first, then second highest element, separated by " and ". For example, if the sample number were 2, based on the example data above the result would be "sodium and potassium". public static int searchHighestSample (double () [] samples, String[] elements, String element) This method will take in a 2D double array of sample values, a String array of element names, and the name of an element to search. If the element exists in the elements array, the method will return the sample number that contains the highest amount of that element. If the element is not in the array, the method will return -1. Deliverables Part 1: Before beginning coding this project, write your algorithms for each method separately in pseudocode (Java code will get zero credit), all in a single document. Make sure that your algorithm steps correspond directly to Java statements (same level of complexity). Submit the pseudocode via Canvas as a doc or pdf file. Part 2: Write the Java program and test your code using the provided JUnit tests. Take a screenshot of the IntelliJ window showing your code passing all JUnit tests. Make sure that the screenshot has your header comment block in it to identify the code. After your program is complete and has been thoroughly tested, submit it to Gradescope. You are allowed only four submissions to Gradescope. After that, the Gradescope component of the score will go to zero automatically.
Step by Step Solution
3.39 Rating (161 Votes )
There are 3 Steps involved in it
The question is asking you to write a program in Java to help analyze soil on Mars and determine the best areas to grow crops The program will take in two Strings one containing the various soil compo... View full answer
Get step-by-step solutions from verified subject matter experts
