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...
-
How is the amount deducted from an employee's wages for income tax determined?
-
Two capacitors (20 F and 30 F) are connected to a 100-V source. Find the energy stored in each capacitor if they are connected in: (a) Parallel (b) Series
-
Is overpopulation a critical problem?
-
ONeill Sporting Goods Co. operates two divisions-the Winter Sports Division and the Summer Sports Division. The following income and expense account were provided from the trial balance as of June...
-
BMX Company has one employee. FICA Social Security taxes are 6.2% of the first $137,700 paid to its employee, and FICA Medicare taxes are 1.45% of gross pay. For BMX, its FUTA taxes are 0.6% and SUTA...
-
Your company wants to bid on the sale of 10 customized machines per year for five years. The initial costs for the project are $1.6 million with a salvage value of $800,000 after five years. The...
-
0 0 Find the reduced row eschelon form of the augmented matrix [A b] for A = 3 rref ([A b]) S= Xp = -1 1/3 0 X = = From the reduced row eschelon form, what is the special solution to As = 0? 0 0 3 3...
-
Let = {, 0, 3, } and B = {B, B, B3, B} be two bases of M2x2(F 4). with - = ['a i] = [0 ] b a a a a a 1 1 1 a b a b 00 a Find the vectors a, a2, a3 and as of a Furthermore, let C = = Check a a a]...
-
Let W= = (b) 3 { [ [29] 3 3w+ 2x + 2y + 4z = 5w+ 4x + 2y + 4z EW E W W = span True True 5w+4x + 2y + 4z 2w + 3x + 5y + 3z. False (c) Show that W is a subspace of M2x2(F7). by writing W as the span of...
-
Given R, express its limits as as a definite integral, identifying the correct interval. n 7 Ra - Z 2 (+2) Rn n n i = 1 b dx
-
On January 2, 2024, Reliable Delivery Service purchased a truck at a cost of $80,000. Before placing the truck in service, Reliable spent $2,200 painting it, $1,200 replacing tires, and $8,600...
-
1: Data definitions and Input-Output functions Write a program that stores the mark allocation weights for 4 assessments as shown in the table below in an array. The program must prompt the user to...
-
Les has collected stamps in his spare time for years. He purchased many of his stamps at a price much lower than the current market value. Les recently lost his job as a carpenter. Since his wife...
-
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...
-
A construction contract differs from contracts that we generally deal with that focus on an easily defined physical object because the physical object can be examined. How is the object of a...
-
What does the owner contribute to the project and what does the contractor contribute to the project?
-
For what type of project is a line-of-balance schedule particularly suited? Identify specific examples.
Study smarter with the SolutionInn App