The first programming assignment involves writing a program that computes the minimum, the maximum and the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The first programming assignment involves writing a program that computes the minimum, the maximum and the average weight of three weights represented in pounds and ounces, and the values for the weight will be hard coded within the program. This program consists of two classes. The first class is the weight class, and this class will have two instance variables. The name of the first valuable is "pounds", and the data type is of integer. The name of the second variable is "ounces", and the data type is a double precision floating point number. Both the instance variables must be private. The Weight class should have four public methods and two private methods, which are as follows: 1. A public constructor that allows the pounds and ounces to be initialized to the values supplied as parameters. 2. A public instance method named less Than that accepts one weight as a parameter and returns whether the weight object on which it is invoked is less than the weight supplied as a parameter. 3. A public instance method named addTo that accepts one weight as a parameter and adds the weight supplied as a parameter to the weight object on which it is invoked. It should normalize the result. 4. A public instance tostring method that returns a string that looks as follows: x lbs y oz, where x is the number of pounds and y the number of ounces. The number of ounces should be displayed with two places to the right of the decimal. You will use this method to print out the weight for display purposes. 5. A private instance method toounces that returns the total number of ounces in the weight object on which it was invoked. This private method will be used (re-used) within the Weight class to help with various computations. 6. A private instance method normalize that normalizes the weight on which it was invoked by ensuring that the number of ounces is less than the number of ounces in a pound. This private method will be used (re-used) within the Weight class to help with various computations. In addition, the class should contain a private named constant that defines the number of ounces in a pound, which is 16. This class must not contain any other public methods. The second class should be named Project 1. It should consist of the following four class (static) methods. 1. A private class method named findMinimum that accepts the three instances of Weight as the parameters and returns the weight that is the smallest. The display will include the values of the three weights, and which one is the minimum. Use the toString() for the display. 2. A private class method named findMaximum that accepts the three instances of Weight as the parameters and returns the weight that is the highest. The display will include the values of the three weights, and which one is the maximum. Use the toString() for the display. 3. A private class method named findAverage that accepts the three instances of Weight as the parameters and returns the average weight. The display will include the values of the three weights, and the value for the average. Use the toString() for the display. Be sure to follow good programming style, which means making all instance variables private, naming all constants, and avoiding the duplication of code. You can create three instances of Weight class inside the main method using the constructor of the Weight class. You can name the three instances of the Weight class as weight1, weight2 and weight3. Next, call the findMinimum, findMaximum and findAverage methods and print out the values. As the input values are hard coded within the program, you can change these values within the code to execute different test runs. Execute three test runs of your program and include them in the test case. Each test run should display the minimum, maximum and the average of the weights. The first programming assignment involves writing a program that computes the minimum, the maximum and the average weight of three weights represented in pounds and ounces, and the values for the weight will be hard coded within the program. This program consists of two classes. The first class is the weight class, and this class will have two instance variables. The name of the first valuable is "pounds", and the data type is of integer. The name of the second variable is "ounces", and the data type is a double precision floating point number. Both the instance variables must be private. The Weight class should have four public methods and two private methods, which are as follows: 1. A public constructor that allows the pounds and ounces to be initialized to the values supplied as parameters. 2. A public instance method named less Than that accepts one weight as a parameter and returns whether the weight object on which it is invoked is less than the weight supplied as a parameter. 3. A public instance method named addTo that accepts one weight as a parameter and adds the weight supplied as a parameter to the weight object on which it is invoked. It should normalize the result. 4. A public instance tostring method that returns a string that looks as follows: x lbs y oz, where x is the number of pounds and y the number of ounces. The number of ounces should be displayed with two places to the right of the decimal. You will use this method to print out the weight for display purposes. 5. A private instance method toounces that returns the total number of ounces in the weight object on which it was invoked. This private method will be used (re-used) within the Weight class to help with various computations. 6. A private instance method normalize that normalizes the weight on which it was invoked by ensuring that the number of ounces is less than the number of ounces in a pound. This private method will be used (re-used) within the Weight class to help with various computations. In addition, the class should contain a private named constant that defines the number of ounces in a pound, which is 16. This class must not contain any other public methods. The second class should be named Project 1. It should consist of the following four class (static) methods. 1. A private class method named findMinimum that accepts the three instances of Weight as the parameters and returns the weight that is the smallest. The display will include the values of the three weights, and which one is the minimum. Use the toString() for the display. 2. A private class method named findMaximum that accepts the three instances of Weight as the parameters and returns the weight that is the highest. The display will include the values of the three weights, and which one is the maximum. Use the toString() for the display. 3. A private class method named findAverage that accepts the three instances of Weight as the parameters and returns the average weight. The display will include the values of the three weights, and the value for the average. Use the toString() for the display. Be sure to follow good programming style, which means making all instance variables private, naming all constants, and avoiding the duplication of code. You can create three instances of Weight class inside the main method using the constructor of the Weight class. You can name the three instances of the Weight class as weight1, weight2 and weight3. Next, call the findMinimum, findMaximum and findAverage methods and print out the values. As the input values are hard coded within the program, you can change these values within the code to execute different test runs. Execute three test runs of your program and include them in the test case. Each test run should display the minimum, maximum and the average of the weights. The first programming assignment involves writing a program that computes the minimum, the maximum and the average weight of three weights represented in pounds and ounces, and the values for the weight will be hard coded within the program. This program consists of two classes. The first class is the weight class, and this class will have two instance variables. The name of the first valuable is "pounds", and the data type is of integer. The name of the second variable is "ounces", and the data type is a double precision floating point number. Both the instance variables must be private. The first programming assignment involves writing a program that computes the minimum, the maximum and the average weight of three weights represented in pounds and ounces, and the values for the weight will be hard coded within the program. This program consists of two classes. The first class is the weight class, and this class will have two instance variables. The name of the first valuable is "pounds", and the data type is of integer. The name of the second variable is "ounces", and the data type is a double precision floating point number. Both the instance variables must be private. The Weight class should have four public methods and two private methods, which are as follows: 1. A public constructor that allows the pounds and ounces to be initialized to the values supplied as parameters. 2. A public instance method named less Than that accepts one weight as a parameter and returns whether the weight object on which it is invoked is less than the weight supplied as a parameter. 3. A public instance method named addTo that accepts one weight as a parameter and adds the weight supplied as a parameter to the weight object on which it is invoked. It should normalize the result. 4. A public instance tostring method that returns a string that looks as follows: x lbs y oz, where x is the number of pounds and y the number of ounces. The number of ounces should be displayed with two places to the right of the decimal. You will use this method to print out the weight for display purposes. 5. A private instance method toounces that returns the total number of ounces in the weight object on which it was invoked. This private method will be used (re-used) within the Weight class to help with various computations. 6. A private instance method normalize that normalizes the weight on which it was invoked by ensuring that the number of ounces is less than the number of ounces in a pound. This private method will be used (re-used) within the Weight class to help with various computations. The Weight class should have four public methods and two private methods, which are as follows: 1. A public constructor that allows the pounds and ounces to be initialized to the values supplied as parameters. 2. A public instance method named less Than that accepts one weight as a parameter and returns whether the weight object on which it is invoked is less than the weight supplied as a parameter. 3. A public instance method named addTo that accepts one weight as a parameter and adds the weight supplied as a parameter to the weight object on which it is invoked. It should normalize the result. 4. A public instance tostring method that returns a string that looks as follows: x lbs y oz, where x is the number of pounds and y the number of ounces. The number of ounces should be displayed with two places to the right of the decimal. You will use this method to print out the weight for display purposes. 5. A private instance method toounces that returns the total number of ounces in the weight object on which it was invoked. This private method will be used (re-used) within the Weight class to help with various computations. 6. A private instance method normalize that normalizes the weight on which it was invoked by ensuring that the number of ounces is less than the number of ounces in a pound. This private method will be used (re-used) within the Weight class to help with various computations. In addition, the class should contain a private named constant that defines the number of ounces in a pound, which is 16. This class must not contain any other public methods. The second class should be named Project 1. It should consist of the following four class (static) methods. In addition, the class should contain a private named constant that defines the number of ounces in a pound, which is 16. This class must not contain any other public methods. The second class should be named Project 1. It should consist of the following four class (static) methods. 1. A private class method named findMinimum that accepts the three instances of Weight as the parameters and returns the weight that is the smallest. The display will include the values of the three weights, and which one is the minimum. Use the toString() for the display. 2. A private class method named findMaximum that accepts the three instances of Weight as the parameters and returns the weight that is the highest. The display will include the values of the three weights, and which one is the maximum. Use the toString() for the display. 3. A private class method named findAverage that accepts the three instances of Weight as the parameters and returns the average weight. The display will include the values of the three weights, and the value for the average. Use the toString() for the display. Be sure to follow good programming style, which means making all instance variables private, naming all constants, and avoiding the duplication of code. You can create three instances of Weight class inside the main method using the constructor of the Weight class. You can name the three instances of the Weight class as weight1, weight2 and weight3. Next, call the findMinimum, findMaximum and findAverage methods and print out the values. As the input values are hard coded within the program, you can change these values within the code to execute different test runs. Execute three test runs of your program and include them in the test case. Each test run should display the minimum, maximum and the average of the weights. 1. A private class method named findMinimum that accepts the three instances of Weight as the parameters and returns the weight that is the smallest. The display will include the values of the three weights, and which one is the minimum. Use the toString() for the display. 2. A private class method named findMaximum that accepts the three instances of Weight as the parameters and returns the weight that is the highest. The display will include the values of the three weights, and which one is the maximum. Use the toString() for the display. 3. A private class method named findAverage that accepts the three instances of Weight as the parameters and returns the average weight. The display will include the values of the three weights, and the value for the average. Use the toString() for the display. Be sure to follow good programming style, which means making all instance variables private, naming all constants, and avoiding the duplication of code. You can create three instances of Weight class inside the main method using the constructor of the Weight class. You can name the three instances of the Weight class as weight1, weight2 and weight3. Next, call the findMinimum, findMaximum and findAverage methods and print out the values. As the input values are hard coded within the program, you can change these values within the code to execute different test runs. Execute three test runs of your program and include them in the test case. Each test run should display the minimum, maximum and the average of the weights. The first programming assignment involves writing a program that computes the minimum, the maximum and the average weight of three weights represented in pounds and ounces, and the values for the weight will be hard coded within the program. This program consists of two classes. The first class is the weight class, and this class will have two instance variables. The name of the first valuable is "pounds", and the data type is of integer. The name of the second variable is "ounces", and the data type is a double precision floating point number. Both the instance variables must be private. The first programming assignment involves writing a program that computes the minimum, the maximum and the average weight of three weights represented in pounds and ounces, and the values for the weight will be hard coded within the program. This program consists of two classes. The first class is the weight class, and this class will have two instance variables. The name of the first valuable is "pounds", and the data type is of integer. The name of the second variable is "ounces", and the data type is a double precision floating point number. Both the instance variables must be private. The Weight class should have four public methods and two private methods, which are as follows: 1. A public constructor that allows the pounds and ounces to be initialized to the values supplied as parameters. 2. A public instance method named less Than that accepts one weight as a parameter and returns whether the weight object on which it is invoked is less than the weight supplied as a parameter. 3. A public instance method named addTo that accepts one weight as a parameter and adds the weight supplied as a parameter to the weight object on which it is invoked. It should normalize the result. 4. A public instance tostring method that returns a string that looks as follows: x lbs y oz, where x is the number of pounds and y the number of ounces. The number of ounces should be displayed with two places to the right of the decimal. You will use this method to print out the weight for display purposes. 5. A private instance method toounces that returns the total number of ounces in the weight object on which it was invoked. This private method will be used (re-used) within the Weight class to help with various computations. 6. A private instance method normalize that normalizes the weight on which it was invoked by ensuring that the number of ounces is less than the number of ounces in a pound. This private method will be used (re-used) within the Weight class to help with various computations. The Weight class should have four public methods and two private methods, which are as follows: 1. A public constructor that allows the pounds and ounces to be initialized to the values supplied as parameters. 2. A public instance method named less Than that accepts one weight as a parameter and returns whether the weight object on which it is invoked is less than the weight supplied as a parameter. 3. A public instance method named addTo that accepts one weight as a parameter and adds the weight supplied as a parameter to the weight object on which it is invoked. It should normalize the result. 4. A public instance tostring method that returns a string that looks as follows: x lbs y oz, where x is the number of pounds and y the number of ounces. The number of ounces should be displayed with two places to the right of the decimal. You will use this method to print out the weight for display purposes. 5. A private instance method toounces that returns the total number of ounces in the weight object on which it was invoked. This private method will be used (re-used) within the Weight class to help with various computations. 6. A private instance method normalize that normalizes the weight on which it was invoked by ensuring that the number of ounces is less than the number of ounces in a pound. This private method will be used (re-used) within the Weight class to help with various computations. In addition, the class should contain a private named constant that defines the number of ounces in a pound, which is 16. This class must not contain any other public methods. The second class should be named Project 1. It should consist of the following four class (static) methods. In addition, the class should contain a private named constant that defines the number of ounces in a pound, which is 16. This class must not contain any other public methods. The second class should be named Project 1. It should consist of the following four class (static) methods. 1. A private class method named findMinimum that accepts the three instances of Weight as the parameters and returns the weight that is the smallest. The display will include the values of the three weights, and which one is the minimum. Use the toString() for the display. 2. A private class method named findMaximum that accepts the three instances of Weight as the parameters and returns the weight that is the highest. The display will include the values of the three weights, and which one is the maximum. Use the toString() for the display. 3. A private class method named findAverage that accepts the three instances of Weight as the parameters and returns the average weight. The display will include the values of the three weights, and the value for the average. Use the toString() for the display. Be sure to follow good programming style, which means making all instance variables private, naming all constants, and avoiding the duplication of code. You can create three instances of Weight class inside the main method using the constructor of the Weight class. You can name the three instances of the Weight class as weight1, weight2 and weight3. Next, call the findMinimum, findMaximum and findAverage methods and print out the values. As the input values are hard coded within the program, you can change these values within the code to execute different test runs. Execute three test runs of your program and include them in the test case. Each test run should display the minimum, maximum and the average of the weights. 1. A private class method named findMinimum that accepts the three instances of Weight as the parameters and returns the weight that is the smallest. The display will include the values of the three weights, and which one is the minimum. Use the toString() for the display. 2. A private class method named findMaximum that accepts the three instances of Weight as the parameters and returns the weight that is the highest. The display will include the values of the three weights, and which one is the maximum. Use the toString() for the display. 3. A private class method named findAverage that accepts the three instances of Weight as the parameters and returns the average weight. The display will include the values of the three weights, and the value for the average. Use the toString() for the display. Be sure to follow good programming style, which means making all instance variables private, naming all constants, and avoiding the duplication of code. You can create three instances of Weight class inside the main method using the constructor of the Weight class. You can name the three instances of the Weight class as weight1, weight2 and weight3. Next, call the findMinimum, findMaximum and findAverage methods and print out the values. As the input values are hard coded within the program, you can change these values within the code to execute different test runs. Execute three test runs of your program and include them in the test case. Each test run should display the minimum, maximum and the average of the weights.
Expert Answer:
Answer rating: 100% (QA)
the implementation for the outlined classes in Java Weight Class public class Weight private int pounds private double ounces private static final int ... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
The second programming project involves writing a program that examines a file of polynomials and determines whether the polynomials in that file are in strictly ascending order using two different...
-
The following data are for four independent process-costing departments. Inputs are added uniformly. Required: Compute the equivalent units of production for each of the preceding departments using...
-
How much current is flowing in a wire 4.80 m long if the maximum force on it is 0.625 N when placed in a uniform 0.0800-T field?
-
When data are categorized as, for example, places of residence (rural, suburban, urban), the most appropriate measure of central tendency is the a. Mean b. Median c. Mode d. Midrange
-
If a well-behaved investment alternative's internal rate of return (IRR) is equal to MARR, which of the following statements about the other measures of worth for this alternative must be true? 1....
-
English Motors, Ltd. (EML), developed a new all-wheel-drive sports utility vehicle. As part of the marketing campaign, EML produced a video tape sales presentation to send to both owners of current...
-
1. Using Fig 2.16 calculate S max of solar constant (irradiance) corresponding to the maximum irradiance over the 25 years presented on the graph (round your answer to 4 digits). 2. Calculate RF max...
-
in the last quarter of 2007, a group of 64 mutual funds had a mean return of 4.3 % with a standard deviation of 7.2%. If a normal model can be used to model them, what percent of the funds would you...
-
1. Download ComputeMeanDeviation.java from M5 Methods module in folio. 2. Modify the program by adding the following two methods: public static double mean (int boundary, int n) public static double...
-
1. Riker Corp has recently paid a dividend of $ 5.2 per share, and the dividends are expected to grow at a constant rate of 3.4 percent per year indefinitely. a. What is the stock value today if the...
-
In a school event, a catering company was serving pizza to 764 people. They served 2 slices for each child and 5 slices for each adult. If the company ordered a total of 2,992 slices of pizza, how...
-
Firm X has 6 . 3 7 percent coupon bonds on the market with 1 3 years to maturity. The bonds make semiannual payments and currently sell for 1 0 2 . 6 3 percent of par. What is the current yield on X...
-
In a cross between a black and a white guinea pig, all members of F1 generation are black. The F2 is made up of 10 black and 3 white guinea pigs. a) Using the correct gene symbol, diagram this cross...
-
A 14.0 m length of wire consists of 7.0 m of copper followed by 7.0 m of aluminum, both of diameter 1.9 mm A voltage difference of 88 mV is placed across the composite wire. What is the total...
-
Activator rod AB exerts on crank BCD a force P directed along line AB. Knowing that P must have a 100-N component perpendicular to arm BC of the crank, determine (a) The magnitude of the force P, (b)...
-
Write a MATLAB program that uses finite differences to solve over the interval x [0, ]. The boundary conditions at x = 0 are y = z = 1 and the boundary conditions at x = are y = z = 0. Your program...
-
Solve the IVP with y(0) = 0 using ode45. dy dt = e~! (4.10.1)
-
Simplify Eq. (8.2.26) for equally spaced data. f[xi, xj] = f(xi) - f(xj) x - xj (8.2.26)
-
Figure18 . 25 shows the series of Walmart daily closing prices between February 2001 and February 2002 (thanks to Chris Albright for suggesting the use of these data, which are publicly available,...
-
Shipments of Household Appliances. The time plot in Figure 18 . 31 shows the series of quarterly shipments (in million dollars) of US household appliances between 1985 and 1989 (dataare available in...
-
Australian Wine Sales. Figure 18 .32 shows time plots of monthly sales of six types of Australian wines (red, rose, sweet white, dry white, sparkling, and fortified) for 19801994. [Data are available...
Study smarter with the SolutionInn App