Martians wants a program to help them analyze the soil on Mars. They want to determine...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Martians wants a program to help them analyze the soil on Mars. They want to determine the best areas to grow crops. You will write a program that will accept, at the command line, two Strings, one containing various soil composition elements and another containing the values found of these elements within the soil samples. A sample of the two Strings are below: carbon-dioxide, magnesium, sodium, potassium chloride,water 8.3,4,5,6.7.2.3,12.5.4.53.9,1.8,34.723.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 elements in the first string are separated by a "," character. The compositions found in the second string are separated into a two-dimensional grid with the rows separated by the "<>" characters and each column separated by a "," character. MoonSamples.java will contain several methods. The first method is the getElements() method. This method takes in a String of elements and returns a one-dimensional String array containing the list of elements. You can use the String method <string>.split(",") to split your string based on the "," character separating the categories. Here is the method header. public static String [] getElements (String inputElement String) { //Your code here } The second method is the getSamples() method. This method takes in a String of sample values and returns a two-dimensional double array containing the elemental composition of each sample. Again, you can use the String method <string>.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 [] [] getSamples (String inputsamplesString) { //Your code here } Here is an example of the two arrays that are created from the first two methods. Note the two- dimensional array will just contain the sample values. This is just an example of the data that might be used to test your code. The elements and their order will not change. However, the samples will change, but will always be numerically labeled starting with the number 1. Sample 1 2 3 4 5 carbon dioxide carbon dioxide 8.3 3.9 6.7 23.4 15.4 magnesium sodium potassium chloride water magnesium sodium potassium chloride water 6.7 12.5 4.5 34.7 1.2 14.3 1.5 7.2 23.7 2.9 39.5 18.2 27.4 3.8 27.4 4.5 1.8 7.4 5.6 5.3 2.3 23.5 18.4 18.5 9.8 The third method is searchForLife(). This method takes in a 2D double array of sample values. It will search all samples for the ones that could support life. The formula for supporting life is as follows: formula for life = (8 carbon dioxide) + (2. magnesium) +sodium + (4. potassium) + chloride + (5. water) } The criteria value that needs to be attained is: 300. If this criteria value is attained or surpassed, then the sample number is returned in an int array. If the first row of data attains the score of 300 or more, the number 1 will be inserted into the first position in the int array. Since not all samples 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. public static int[] searchForLife (double [] [] samples) { //Your code here } The fourth method is searchHighestElements (). This method will take in a String array of elements, a 2D double array of sample values, and a sample to search. It will search that sample and will return a string containing the two elements that are found in the highest amount for that sample in the order of highest first, then second highest element. public static String searchHighestElements (double [][] samples, Sring [] elements, int sampleNum) { //Your code here The fifth method is search HighestSample(). This method will take in a String array of elements, a 2D double array of sample values, and an element to search. It will search for and return the sample number that contains the highest amount of that element. public static int searchHighestSample (double [][] samples, String [] elements, String element) { //Your code here } Lastly, you will define a main method. The main method will do the following: • Accept, at the command line, two Strings, one containing various soil composition elements and another containing the values found of these elements within the soil samples •Pass the first command line argument to the getElements() method and store the result • Pass the second command line argument to the getSamples() method 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 print the result • Call searchHighestSample(), passing in the results of getSamples() and getElements() and print the result The main method will not be tested by the test cases. You should use your own output statements to test the output of your code based on the inputs given. Below is a sample run: The samples that contain life are: 4 5 The highest elements for sample 1 are chloride and carbon- dioxide The sample with the highest value of the element water is 5 You can assume all arguments passed in on the command line are valid Strings for this program. Before beginning this project, you will document your algorithm as a list of steps to take you from your inputs to your outputs. This algorithm will be due on paper at the beginning of class on the day it is due. This will be graded and returned to you. It will be your responsibility to understand and correct any errors you might have with your algorithm. Each step will be added as a comment block within your code. You will have the comment block right above the code that performs the actions specified. For example, before your lines of code that ask the user for inputs, you would have a comment block that states what inputs you are requesting from the user. Martians wants a program to help them analyze the soil on Mars. They want to determine the best areas to grow crops. You will write a program that will accept, at the command line, two Strings, one containing various soil composition elements and another containing the values found of these elements within the soil samples. A sample of the two Strings are below: carbon-dioxide, magnesium, sodium, potassium chloride,water 8.3,4,5,6.7.2.3,12.5.4.53.9,1.8,34.723.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 elements in the first string are separated by a "," character. The compositions found in the second string are separated into a two-dimensional grid with the rows separated by the "<>" characters and each column separated by a "," character. MoonSamples.java will contain several methods. The first method is the getElements() method. This method takes in a String of elements and returns a one-dimensional String array containing the list of elements. You can use the String method <string>.split(",") to split your string based on the "," character separating the categories. Here is the method header. public static String [] getElements (String inputElement String) { //Your code here } The second method is the getSamples() method. This method takes in a String of sample values and returns a two-dimensional double array containing the elemental composition of each sample. Again, you can use the String method <string>.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 [] [] getSamples (String inputsamplesString) { //Your code here } Here is an example of the two arrays that are created from the first two methods. Note the two- dimensional array will just contain the sample values. This is just an example of the data that might be used to test your code. The elements and their order will not change. However, the samples will change, but will always be numerically labeled starting with the number 1. Sample 1 2 3 4 5 carbon dioxide carbon dioxide 8.3 3.9 6.7 23.4 15.4 magnesium sodium potassium chloride water magnesium sodium potassium chloride water 6.7 12.5 4.5 34.7 1.2 14.3 1.5 7.2 23.7 2.9 39.5 18.2 27.4 3.8 27.4 4.5 1.8 7.4 5.6 5.3 2.3 23.5 18.4 18.5 9.8 The third method is searchForLife(). This method takes in a 2D double array of sample values. It will search all samples for the ones that could support life. The formula for supporting life is as follows: formula for life = (8 carbon dioxide) + (2. magnesium) +sodium + (4. potassium) + chloride + (5. water) } The criteria value that needs to be attained is: 300. If this criteria value is attained or surpassed, then the sample number is returned in an int array. If the first row of data attains the score of 300 or more, the number 1 will be inserted into the first position in the int array. Since not all samples 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. public static int[] searchForLife (double [] [] samples) { //Your code here } The fourth method is searchHighestElements (). This method will take in a String array of elements, a 2D double array of sample values, and a sample to search. It will search that sample and will return a string containing the two elements that are found in the highest amount for that sample in the order of highest first, then second highest element. public static String searchHighestElements (double [][] samples, Sring [] elements, int sampleNum) { //Your code here The fifth method is search HighestSample(). This method will take in a String array of elements, a 2D double array of sample values, and an element to search. It will search for and return the sample number that contains the highest amount of that element. public static int searchHighestSample (double [][] samples, String [] elements, String element) { //Your code here } Lastly, you will define a main method. The main method will do the following: • Accept, at the command line, two Strings, one containing various soil composition elements and another containing the values found of these elements within the soil samples •Pass the first command line argument to the getElements() method and store the result • Pass the second command line argument to the getSamples() method 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 print the result • Call searchHighestSample(), passing in the results of getSamples() and getElements() and print the result The main method will not be tested by the test cases. You should use your own output statements to test the output of your code based on the inputs given. Below is a sample run: The samples that contain life are: 4 5 The highest elements for sample 1 are chloride and carbon- dioxide The sample with the highest value of the element water is 5 You can assume all arguments passed in on the command line are valid Strings for this program. Before beginning this project, you will document your algorithm as a list of steps to take you from your inputs to your outputs. This algorithm will be due on paper at the beginning of class on the day it is due. This will be graded and returned to you. It will be your responsibility to understand and correct any errors you might have with your algorithm. Each step will be added as a comment block within your code. You will have the comment block right above the code that performs the actions specified. For example, before your lines of code that ask the user for inputs, you would have a comment block that states what inputs you are requesting from the user.
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Fundamentals of Cost Accounting
ISBN: 978-0077398194
3rd Edition
Authors: William Lanen, Shannon Anderson, Michael Maher
Posted Date:
Students also viewed these programming questions
-
Smart housing Inc. is negotiating a deal to build a house. The owner wants to start in early spring when the weather begins to moderate and build through the summer into the fall. The completion time...
-
How can an investor make money using the buy and hold technique?
-
What limit must be calculated to find the rate of change of a function g(t) at t = t 0 ?
-
Nereus Montemayor was an employee of VZ Hogs, a company that raises hogs and produces hog feed. VZ Hogs used an extruder manufactured by Sebright Products, Inc. to create hog feed out of discarded...
-
Job costing, accounting for manufacturing overhead, budgeted rates. The Fasano Company uses a job-costing system at its Dover, Delaware, plant. The plant has a machining department and a finishing...
-
In a random walk suppose that at t = (n - 1)At the particle is located at x = max. The assumption is that at t = nAt the particle will have moved to x = (m+1)Ax with probability 3/4 or to x = (m-3)Ax...
-
In problem 8.16, a college chemistry instructor thinks the use of embedded tutors will improve the success rate in introductory chemistry courses. The instructor carried out a hypothesis test and...
-
In Fig, a constant external force P = 140 N is applied to a 20-kg box, which is on a rough horizontal surface. The force pushes the box a distance of 8.0 m, in a time interval of 8.0 s, and the speed...
-
Enumerate the distinguishing characteristics inherent to various quality management philosophies, elucidating the nuanced principles that define each approach.
-
Shake Shacks Vegan Burgers reports the following information from its sales budget: Expected Sales: May $133,000 June 120,000 July 155,000 All sales are on credit and cash receipts are expected to be...
-
A. Abed bought a warehouse and land for $950,000. Along with the purchase price, Abed made the following expenditures related to the acquisition: brokers commission, $47,000; title insurance,...
-
"What are the primary distinctions between Additive Manufacturing and Traditional Manufacturing?"
-
Consider the portfolios presented in the following table: Table 6: Returns Portfolio 1 Portfolio 2 Portfolio 3 8.1% -2.1% -2.1% -6.8% 1.1% 6.0% 3.0% 3.0% -2.8% -5.2% 2.0% 4.8% 4.8% -0.1% -0.1% a....
-
Can I ask how these come up with the answer...full solution on how the given was divided. * Answes Given Data A@ = 104 J 100c 100t 273.15K %3D = 373.15 k Find As change in entooPY is given by AS T...
-
When a company has a contract involving multiple performance obligations, how must the company recognize revenue?
-
Refer to the facts in Problem 11-47. Cost records obtained from Farmington Components show the following cost structure in their departments: Required a. If Farmington outsources the Engineering...
-
The controller of Northwest Hardware has just received two forecasts for sales in the Montana District for the coming year. Based on an econometric analysis of consumer spending and economic trends,...
-
Ajax Manufacturing repairs aircraft engines. The companys purchasing department supports its two departments, Defense and Commercial. The Defense division has contracts with the Department of Defense...
-
What are the functions of regulatory bodies in safety assessment of nuclear reactors?
-
What is the probabilistic safety assessment (PSA) and its role in safety assessment of nuclear reactors. Explain the level of maturity achieved by this methodology over the years.
-
What are the advantages and disadvantages of "Passive Safety" in nuclear reactors?
Study smarter with the SolutionInn App