Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi, if anyone could help me with this homework problem. Thank you so much! 2. Create a normal (POJO, JavaBean) but immutable class to represent,
Hi, if anyone could help me with this homework problem. Thank you so much!
2. Create a normal (POJO, JavaBean) but immutable class to represent, i. e. model, samples of dirt. Following the steps shown in "Assignment: Tutorial on Creating Classes in IntelliJ", create the class ina file of its own in the same package as class Main. Name the class an appropriate name. The class must have (a) private field variables to hold the percent of sand, clay and other materials. The range of values for each of these is zero to one inclusive, i. e. [0, 1]. The three values stored must add up to 1 (b) a private field variable to hold the pH value of the sample. The range of values for pH in the soil is zero to 14, i. e. [0, 14] (c) a public getter (accessor) method for each private field variable. The getters must not have parameters (d) a public default constructor, i. e. a constructor without parameters. (e) a parametrized constructor, i. e. a constructor with parameters, one parameter each for sand, clay and pH. Note that the value of other materials can be calculated given the percent of sand and clay 3. Create a class to represent, i. e. model, a collection of samples of dirt. Following the steps shown in Assignment: Tutorial on Creating Classes in IntelliJ", create the class in a file of its own in the same package as class Main. Name the class an appropriate name. The class will store dirt class objects in an array and have methods to provide information about the samples stored. The class must have (a) a private reference variable for an array of the dirt class created in step 2 (b) a private variable to keep track of the number of dirt objects stored in the array (c) a public default constructor that creates a default size dirt class array object, assigning its reference to the variable created in (a). The default size must be 2 elements or greater. (d) a public parametrized constructor that creates a dirt class array object of the size passed in as a parameter. The array size must be valid or an array of the default size is created. The reference of the array is assigned to the variable created in (a) 4. In method main of class Main, create a program that uses an object of the dirt samples collection class and, as needed, objects of the dirt samples class to (a) at start up, have the user input the number of dirt samples to be stored in the dirt samples collection class object by calls to the appropriate method. (b) allow the user to enter the values to be used in the dirt samples, which are then stored in the dirt samples collection object by calls to the appropriate method(s) of the dirt samples collection class object. If the data entered is not valid, the entry must be rejected and repeated. (c) once all the data has been entered, use calls the appropriate dirt samples collection class object to show the user the i. sample count ii. maximum number of samples that can be stored ii. average percentage of clay, sand, other materials and pH of the samples stored iv. high percentage of clay, sand, other materials and pH of the samples stored v. low percentage of clay, sand, other materials and pH of the samples stored The following is provided for example purposes only. Your program's user input may look completely different from this as long as it is complete, clear and functional. Enter the number of samples: 5 Sample 1 Sand Clay must be
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started