1. Create three classes Data, Single, and List, as follows: a. Create an abstract class Data,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Create three classes Data, Single, and List, as follows: a. Create an abstract class Data, which will contain no instance variables, no constructor, and only one method: double valueOf() which returns 0.0. b. Create a class Single which is a subclass of Data, and which will store one double value. Provide a constructor to initialize the value. Override the valueOf() method so that it returns this value. c. Create a class List which is a subclass of Data, and which will store a double[] array. Provide a constructor List (double[] a) which will initialize this array. Override the valueOf() method so that it returns the sum of all the doubles in the array. Note that this will always be a full array, not a partially full array. There will be no separate length variable. 2. Start with the Template Lab7.java file. It creates a list of Data objects (a mixture of Single and List) using a Data[] myData array. Take a look at it. Add a loop at the indicated position which will find and print the sum of every number that appears in myData, whether it appears in a Single or in a List, using valueOf(). It should print the line The sum of everything is 35.8 SILVER Creating a bigger class hierarchy 1. Add a length() method to the List class which returns the size of the list stored in the object. You are not allowed to add a length() method to the Data or Single classes. (This would be a logical thing to do, but it would destroy the purpose of the question.) 2. Add more code to the TemplateLab7.java file at the indicated position which will find and print the total number of values that appear anywhere in myData. It should print the line There are 7 values in total. as well as the output line from the Bronze exercise. 1. Create three classes Data, Single, and List, as follows: a. Create an abstract class Data, which will contain no instance variables, no constructor, and only one method: double valueOf() which returns 0.0. b. Create a class Single which is a subclass of Data, and which will store one double value. Provide a constructor to initialize the value. Override the valueOf() method so that it returns this value. c. Create a class List which is a subclass of Data, and which will store a double[] array. Provide a constructor List (double[] a) which will initialize this array. Override the valueOf() method so that it returns the sum of all the doubles in the array. Note that this will always be a full array, not a partially full array. There will be no separate length variable. 2. Start with the Template Lab7.java file. It creates a list of Data objects (a mixture of Single and List) using a Data[] myData array. Take a look at it. Add a loop at the indicated position which will find and print the sum of every number that appears in myData, whether it appears in a Single or in a List, using valueOf(). It should print the line The sum of everything is 35.8 SILVER Creating a bigger class hierarchy 1. Add a length() method to the List class which returns the size of the list stored in the object. You are not allowed to add a length() method to the Data or Single classes. (This would be a logical thing to do, but it would destroy the purpose of the question.) 2. Add more code to the TemplateLab7.java file at the indicated position which will find and print the total number of values that appear anywhere in myData. It should print the line There are 7 values in total. as well as the output line from the Bronze exercise. 1. Create three classes Data, Single, and List, as follows: a. Create an abstract class Data, which will contain no instance variables, no constructor, and only one method: double valueOf() which returns 0.0. b. Create a class Single which is a subclass of Data, and which will store one double value. Provide a constructor to initialize the value. Override the valueOf() method so that it returns this value. c. Create a class List which is a subclass of Data, and which will store a double[] array. Provide a constructor List (double[] a) which will initialize this array. Override the valueOf() method so that it returns the sum of all the doubles in the array. Note that this will always be a full array, not a partially full array. There will be no separate length variable. 2. Start with the Template Lab7.java file. It creates a list of Data objects (a mixture of Single and List) using a Data[] myData array. Take a look at it. Add a loop at the indicated position which will find and print the sum of every number that appears in myData, whether it appears in a Single or in a List, using valueOf(). It should print the line The sum of everything is 35.8 SILVER Creating a bigger class hierarchy 1. Add a length() method to the List class which returns the size of the list stored in the object. You are not allowed to add a length() method to the Data or Single classes. (This would be a logical thing to do, but it would destroy the purpose of the question.) 2. Add more code to the TemplateLab7.java file at the indicated position which will find and print the total number of values that appear anywhere in myData. It should print the line There are 7 values in total. as well as the output line from the Bronze exercise. 1. Create three classes Data, Single, and List, as follows: a. Create an abstract class Data, which will contain no instance variables, no constructor, and only one method: double valueOf() which returns 0.0. b. Create a class Single which is a subclass of Data, and which will store one double value. Provide a constructor to initialize the value. Override the valueOf() method so that it returns this value. c. Create a class List which is a subclass of Data, and which will store a double[] array. Provide a constructor List (double[] a) which will initialize this array. Override the valueOf() method so that it returns the sum of all the doubles in the array. Note that this will always be a full array, not a partially full array. There will be no separate length variable. 2. Start with the Template Lab7.java file. It creates a list of Data objects (a mixture of Single and List) using a Data[] myData array. Take a look at it. Add a loop at the indicated position which will find and print the sum of every number that appears in myData, whether it appears in a Single or in a List, using valueOf(). It should print the line The sum of everything is 35.8 SILVER Creating a bigger class hierarchy 1. Add a length() method to the List class which returns the size of the list stored in the object. You are not allowed to add a length() method to the Data or Single classes. (This would be a logical thing to do, but it would destroy the purpose of the question.) 2. Add more code to the TemplateLab7.java file at the indicated position which will find and print the total number of values that appear anywhere in myData. It should print the line There are 7 values in total. as well as the output line from the Bronze exercise.
Expert Answer:
Answer rating: 100% (QA)
Here is the implementation of the classes Data Single and List as described in the question java abs... View the full answer
Related Book For
Applied Regression Analysis and Other Multivariable Methods
ISBN: 978-1285051086
5th edition
Authors: David G. Kleinbaum, Lawrence L. Kupper, Azhar Nizam, Eli S. Rosenberg
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
In Exercises 3336, use possible symmetry to determine whether each graph is the graph of an even function, an odd function, or a function that is neither even nor odd. ------ -2, y CI (0,4) 2 14...
-
What is the difference between an operating line of credit and a bank overdraft?
-
Find the point on each line where y is equal to 740.0. a. y = 16.8x + 405 b. y = -7.4 + 4.3(x - 3.2)
-
Extreme Machine manufactures machines and parts for various industries; they have an office in Youngstown, Ohio. Avery Dennison manufactures and sells labels from a plant in Mentor, Ohio. They use...
-
Revenues, production, and purchases budgets. The Suzuki Co. in Japan has a division that manufactures two-wheel motorcycles. Its budgeted sales for Model G in 2010 are 900,000 units. Suzukis target...
-
Oil having a density of 921 kg/m floats on water. A rectangular block of wood 4.41 cm high and with a density of 963 kg/m floats partly in the oil and partly in the water. The oil completely covers...
-
The following information is available for a production process for the last period: Material input 200 kg at $4 per kg Labour input 100 hours at $15 per hour Department overhead $1,000 Transfer to...
-
Nearly every business professor and philosopher have weighed in with models and tests that can be used for resolving ethical issues. The following sections offer summaries of the thoughts and models...
-
Using an Internet browser or a colleges library research portal, identify a recent article from such business news outlets as The Wall Street Journal, Bloomberg Business, Forbes, or Fast Company that...
-
We have a tendency to look at folks who get into ethical and legal trouble and say, I know I would never behave like that. You probably would not, but you are only seeing them at their last step. You...
-
Assume you are a cross-cultural anthropologist. In this role, please visit multiple public places that are frequented by one or more ethnic or cultural groups. Observe four to five behaviors that...
-
If \(n \geq 3\), then every \(n \times n\) matrix with any repeated eigenvalues is defective. (True/False)
-
Treatment of compound D with LIAIH4 followed by H20 forms compound E. D shows a molecular ion in its mass spectrum at m/z 71 and IR absorptions at 3600 - 3200 and 2263 cm-1. E shows a molecular ion...
-
Problem 2. (0.6 points, 0.2 points for each question) (a) A company turns its inventory 2 times a month. Its months-of-supply = Its days-of-supply = Please show your analysis below: _months. days. (1...
-
The accompanying SAS computer output relates to the house price data of Problem 10 in Chapter 8. Use this output and, if necessary, the output associated with Problem 9 in Chapter 9 to answer the...
-
In an environmental engineering study of a certain chemical reaction, the concentrations of 18 separately prepared solutions were recorded at different times (three measurements at each of six...
-
The susceptibility of catfish to a certain chemical pollutant was determined by immersing individual fish in 2 liters of an emulsion containing the pollutant and measuring the survival time in...
-
Fixed costs can significantly affect the profitability of a small business. One way to reduce fixed costs might be to outsource the company's sales and marketing functions to third parties. For...
-
Each firm in a competitive market has a cost function of \(C=q^{2}\), so its marginal cost function is \(M C=2 q\). The market demand function is \(Q=24-p\). Determine the long-run equilibrium price,...
-
Uber, a car-for-hire service that connects passengers with private drivers, presently operates in 613 cities worldwide. Lower overheads allow Uber to charge significantly less than a taxi company...
Study smarter with the SolutionInn App