Placeholder

CMIS 242 Project 1 Minimum Maximum and Average

$19.00

Description

The first programming project involves writing a program that computes the minimum, the maximum and the average weight of a collection of weights represented in pounds and ounces that are read from an input file. This program consists of two classes. The first class is the Weight class, which is specified in integer pounds and ounces stored as a double precision floating point number. It should have five public methods and two private methods:
A public constructor that allows the pounds and ounces to be initialized to the values supplied as parameters.
A public instance method named lessThan 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.
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.
A public instance method named divide that accepts an integer divisor as a parameter. It should divide the weight object on which the method is invoked by the supplied divisor and normalize the result.
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 three places to the right of the decimal.
A private instance method toOunces that returns the total number of ounces in the weight object on which is was invoked.
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.
Both instance variable must be private. In addition the class should contain a private named constant that defines the number of ounces in a pound, which is 16. The must not contain any other public methods.
The second class should be named Project1. It should consist of the following four class (static) methods.
The main method that reads in the file of weights and stores them in an array of type Weight. It should then display the smallest, largest and average weight by calling the remaining three methods. The user should be able to select the input file from the default directory by using the JFileChooser class.
The input file should contain one weight per line. If the number of weights in the file exceeds 25, an error message should be displayed and the program should terminate.
A private class method named findMinimum that accepts the array of weights as a parameter together with the number of valid weights it contains. It should return the smallest weight in that array.
A private class method named findMaximum that accepts the array of weights as a parameter together with the number of valid weights it contains. It should return the largest weight in that array.
A private class method named findAverage that accepts the array of weights as a parameter together with the number of valid weights it contains. It should return the average of all the weights in that array.
Be sure to follow good programming style, which means making all instance variables private, naming all constants and avoiding the duplication of code. Furthermore you must select enough different input files to completely test the program.
SCREENSHOTS
SOLUTION
PAYMENT
CMIS 242 Project 1
CMIS 242 Project 1 ScreenShot
CMIS 242 first programming project
The solution consists of:
All Java programs for this assignment.
A Netbeans Project in case you want to run theses programs on your computer.
Screenshots while running programs
Attachments [Move over files to preview content of those files]
CMIS242_Project_1.zip (190.88 KB)
input
PRJ1WeightLess.txt
PRJ1WeightMore.txt
Netbeans Project
CMIS242Project1
pom.xml
PRJ1WeightLess.txt
PRJ1WeightMore.txt
src
main
java
Project1.java
Weight.java
test
java
target
classes
.netbeans_automatic_build
Project1.class
Weight.class
generated-sources
annotations
maven-status
maven-compiler-plugin
compile
default-compile
createdFiles.lst
inputFiles.lst
test-classes
.netbeans_automatic_build
readme.txt
Screenshots
CMIS242-PROJECT-1-SCREENSHOT-1.png
CMIS242-PROJECT-1-SCREENSHOT-2.png
CMIS242-PROJECT-1-SCREENSHOT-3.png
Source Code
Project1.java
Weight.java
Preview PRJ1WeightLess.txt
233, 7500
23, 5000
56, 3125
79, 0625
45, 8125
76, 3750 76, 6250 15, 4375 56, 3750 345, 1230 34, 4375 654, 6875
8, 0000
5, 3125
987, 2500
56, 8125
24, 2500
92, 0000
Preview PRJ1WeightMore.txt
233, 7500
23, 5000
56, 3125
79, 0625
45, 8125
75, 4375 76, 3750 76, 6250 11, 1875 15, 4375 23, 7500 56, 3750
345, 1230
34, 4375
654, 6875
8, 0000
5, 3125
987, 2500
Preview PRJ1WeightLess.txt
233, 7500
23, 5000
56, 3125
79, 0625
45, 8125
76, 3750 76, 6250 15, 4375 56, 3750 345, 1230 34, 4375 654, 6875
8, 0000
5, 3125
987, 2500
56, 8125
24, 2500
92, 0000
Preview PRJ1WeightMore.txt
233, 7500
23, 5000
56, 3125
79, 0625
45, 8125
75, 4375 76, 3750 76, 6250 11, 1875 15, 4375 23, 7500 56, 3750
345, 1230
34, 4375
654, 6875
8, 0000
5, 3125
987, 2500
Preview Project1.java
xxxxxx xxxx.xx.xxxxxxxxxxxxxxxxx;
xxxxxx xxxx.xxxx.xxxxxxxxx;
xxxxxx xxxx.xxxx.xxxxxxx.xxxxx;
xxxxxx xxxx.xxxx.xxxxxxx.xxxxxx;
xxxxxx xxxxx.xxxxx.xxxxxxxxxxx;
public class Project1 extends javax.swing.JFrame {

private Weight[] weights;
private JFileChooser fileChooser = new JFileChooser();

public Project1() {
initComponents();
}

private Weight findMinimum(Weight[] w) {
Weight minWeight = null;
xxx (xxx x = 0; x < x.xxxxxx; x++) { xx (xxxxxxxxx == xxxx || x[x].xxxxxxxx(xxxxxxxxx)) { xxxxxxxxx = x[x]; } } xxxxxx xxxxxxxxx; Preview Weight.java xxxxxx xxxxxx(xxx x, xxxxxx x) { xxxx.xxxxxx = x; xxxx.xxxxxx = x; } //checks if the incoming weight object is less than the current object weight public boolean lessThan(Weight w) { //first comparison between pounds of the objects, if current object is less, then return true if (this.pounds < w.pounds) { return true; } //else if it is less then return false else if (this.pounds > w.pounds) { return false; } //else if both are equal then we compare the ounces else { //if current object ounces is less than we return true else false if (this.ounces < w.ounces) { xxxxxx xxxx; } xxxx { xxxxxx xxxxx; } } } Preview readme.txt xx xxxx xxxxxxxx, xx xxxxxxxx xxxxxx xxxx xxx xxxxxxxx xxxxxxx. xxx xxx xxxxxxx xxxxxxxx xx xxxx xxx xxx xxx xxxxxxxx xxxxxxx xx xxx xxx xxxx xxx xx xxxxxx xxxxxxx xxx xxxx xxxxxx xxxx xx "xxx" xxxxxx. If you are using Netbean. Please choose Netbeans and JDK version as follow: based on the NetBeans release documentation, here is a summary of the JDK versions you can use with all recent versions of NetBeans: NetBeans 11.0: JDK 8, JDK 11, JDK 12 NetBeans 11.1: JDK 8, JDK 11, JDK 12 xxxxxxxx 11.2: xxx 8, xxx 11, xxx 13 xxxxxxxx 11.3: xxx 8, xxx 11, xxx 14 xxxxxxxx 12.0: xxx 8, xxx 11, xxx 14 Preview Project1.java xxxxxx xxxx.xx.xxxxxxxxxxxxxxxxx; xxxxxx xxxx.xxxx.xxxxxxxxx; xxxxxx xxxx.xxxx.xxxxxxx.xxxxx; xxxxxx xxxx.xxxx.xxxxxxx.xxxxxx; xxxxxx xxxxx.xxxxx.xxxxxxxxxxx; public class Project1 extends javax.swing.JFrame {private Weight[] weights; private JFileChooser fileChooser = new JFileChooser();public Project1() { initComponents(); }private Weight findMinimum(Weight[] w) { Weight minWeight = null; xxx (xxx x = 0; x < x.xxxxxx; x++) { xx (xxxxxxxxx == xxxx || x[x].xxxxxxxx(xxxxxxxxx)) { xxxxxxxxx = x[x]; } } xxxxxx xxxxxxxxx; Preview Weight.java xxxxxx xxxxxx(xxx x, xxxxxx x) { xxxx.xxxxxx = x; xxxx.xxxxxx = x; } //checks if the incoming weight object is less than the current object weight public boolean lessThan(Weight w) { //first comparison between pounds of the objects, if current object is less, then return true if (this.pounds < w.pounds) { return true; } //else if it is less then return false else if (this.pounds > w.pounds) { return false; } //else if both are equal then we compare the ounces else { //if current object ounces is less than we return true else false if (this.ounces < w.ounces) { xxxxxx xxxx; } xxxx { xxxxxx xxxxx; } } } Price: $19 You May Also Like: CMIS 242 Project 2 Computes the Sales Tax CMIS 242 Project 3 Draws Two Types of Shapes CMIS 242 Project 4 Manage a Real Estate Database

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.