Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help and show detailed Java code, thanks A incomplete definition of a class Volume is given below: public class Volume private double value-(12.5, 20,

Please help and show detailed Java code, thanks

image text in transcribed

A incomplete definition of a class Volume is given below: public class Volume private double value-(12.5, 20, 22.3, 5.8 (i) Copy and put it in a new class. Write a method tostring of the class, which does not have any parameters and returns a string containing all the values separated by newlines. When the string is printed, cach value should appear on a line in the ascending order of their indexes. Copy the content of the method as the answers to this part. (ii) Write another class TestVolume in a separate file with a method main to test the class Volume. In main),create a Vol ume object volume and print its values by calling tostring ) Run the program. Copy the content of the file and the output showing the message as the answers to this part. (iii) Add a method decreasePercent (int index, double percent) to the Volume class which decreases the element with subscript index of the value array by the percentage percent without retuming anything. Also add a method getValue (int index) to return value [index]. Copy the content of the methods as the answers to this part. (iv) Add another method countLess (double threshold) to the Volume class which retums the number of values which are less than threshold. Copy the content of the method as the answers to this part. (v) Add another method minimumIndex) to the Volume class which returns the index of the minimum value in the array. Copy the content of the method as the answers to this part. You can assume there is only one minimum valuc (vi) Add another method trimmedMean to the Volume class which returns the average value which excludes the (unique) largest value and (unique) smallest value in the calculation. You should use minimumIndex ) to get the index of the minimum value. Note that this method should work without any modifications when the number of values, which is at least three, is changed. Copy the content of the method as the answers to this part. (vii) Perform the tasks listed below in main of TestVolume * print the second value from the left, decrease it by 20% using the method decreasePercent ,and print the new value calling count Less )to count the number of values less than 10 and then print it print the index of the minimum value and the trimmed mean. Run the program. Copy the content of the cdass and the output as the answers to this part

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Is there just cause to dismiss Bonita? Explain your answer.

Answered: 1 week ago

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago