Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with my java programming please! It would really help me study for my exam. 1.Create project in intelliJ 2.Create a normal (POJO, JavaBean) but

Help with my java programming please! It would really help me study for my exam.

1.Create project in intelliJ

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 in a 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).

(e)

two public methods to add dirt class objects to the list stored in the array, but only if there is room in the array.

I.One method must receive as a parameter a reference to a dirt class object to be added to the list of dirt class objects stored in the array.

Ii. One method must receive as a parameters the percent of clay, percent of sand and the pH value of a sample. This method will then create a dirt class object and add it to the list of dirt class objects stored in the array.

(f)

public methods to return the

I.number of dirt samples stored.

Ii. maximum number of dirt samples that can be stored.

(g)

public methods to return the

I.average clay percentage in the samples stored.

Ii. average sand percentage in the samples stored.

Iii. average other material percentage in the samples stored.

Iv. average pH of the samples stored.

(h)

public methods to return the highest percentage in the samples stored of

I.clay

Ii. sand

Iii. other materials

Iv. pH

(i) public methods to return the lowest percentage in the samples stored of

I.clay

Ii. sand

Iii. other materials

Iv. pH

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

iii.

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

Example of User Input (user input in red)

The following is provided for example purposes only. Your programs 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 <= 1

Enter sand percent:

0.77

Enter clay percent:

0.12

Enter pH (0 14):

7.07

Sample Accepted.

Sample 2

Sand + Clay must be <= 1

Enter sand percent:

0.9

Enter clay percent:

0.05

Enter pH (0 14):

15.92 <== example of a bad pH value entry

Bad values. Please reenter.

Sample 2

Sand + Clay must be <= 1

Enter sand percent:

0.13

Enter clay percent:

0.44

Enter pH (0 14):

1.62

Sample Accepted.

Sample 3

Sand + Clay must be <= 1

Enter sand percent:

0.92

Enter clay percent:

0.04

Enter pH (0 14):

13.11

Sample Accepted.

Sample 4

Sand + Clay must be <= 1

Enter sand percent:

0.29

Enter clay percent:

0.36

Enter pH (0 14):

0.25

Sample Accepted.

Sample 5

Sand + Clay must be <= 1

Enter sand percent:

0.88

Enter clay percent:

0.6

Enter pH (0 14):

7.98

Bad values. Please reenter. <== example of bad values

Sample 5

Sand + Clay must be <= 1

Enter sand percent:

0.44

Enter clay percent:

0.28

Enter pH (0 14):

6.83

Sample Accepted.

Sample 6

Sand + Clay must be <= 1

Enter sand percent:

0.61

Enter clay percent:

0.2

Enter pH (0 14):

13.55

No room for sample.

Example of Report to User

The following is provided for example purposes only. Your programs user report output may look completely different from this as long as it is complete, clear and functional.

Sample Count: 5

Maximum Samples: 5

Average Clay: 0.248

Clay High: 0.44

Clay Low: 0.04

Average Sand: 0.510

Sand High: 0.92

Sand Low: 0.13

Average Other: 0.242

Other High: 0.43

Other Low: 0.04

Average pH: 5.776

pH High: 13.11

pH Low: 0.25

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Occupational Safety and Health Act?

Answered: 1 week ago

Question

Discuss globalization issues for small to medium-sized businesses.

Answered: 1 week ago