CMIS242 Intermediate Programming Assignment

Assignment Help Programming Languages
Reference no: EM132619209

CMIS242 Intermediate Programming - University of Maryland Global Campus

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 a data file. This program consists of two parts. The first part is the Weight class and the second part is the Program Core.

The Weight Class is specified in integer pounds and ounces stored as a double precision floating point number, that is, a percentage of a pound. 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 four 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. Two processes occur in this method. The first process takes the value read in from a data file that is a percentage of a pound and it is checked that is one of fifteen acceptable numbers using modulo of integer division (See the Conversion Table). If the value is not an acceptable number, then a message is displayed indicating that the value is not acceptable. That value is not included in the array used to determine the average. If the value is acceptable, the percentage of a pound is converted into one of the fifteen ounces with integer division. That value is returned.

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 variables 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 class must not contain any other public methods.

The second part is the Program Core. 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 data file from a default directory by using the JFileChooser class. Reading the data can follow the coding used in ReadEmails.java found in Week 2 |Code Examples. Attached to this assignment are two files containing weights: PRJ1WeightsLess and PRJ1WeightsMore. The second file contains more than 25 entries. The data file contains one weight per line divided into two parts: the pound as integer and the percentage of a pound as a float. If the number of weights in the file exceeds 25, an error message should display, and the program should terminate with a message.

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 data files for testing and enough weights to completely test the program.

Reference no: EM132619209

Questions Cloud

What was the most important thing you learned from the clip : After watching the Change is good movie clip, list three ways in which change can impact your leadership at work and two ways it can impact your leadership.
How you will implement the theories in your leadership style : Select three leadership theories and explain how you will implement those theories in your leadership style. Be sure to include specific examples.
How social worker might address the barrier on an individual : Explain potential barriers or challenges this family might encounter that is related to diversity. Provide evidence from scholarly resources to support.
How much should MJE company account as Product B : Inventories shall be measured at lower of cost and NRV. How much should MJE company account as Product B ending inventory
CMIS242 Intermediate Programming Assignment : CMIS242 Intermediate Programming Assignment Help and Solution, University of Maryland Global Campus - Assessment Writing Service
Describe the disadvantages for both employees and business : In your first post in this discussion, you will become familiar with the case of Abercrombie & Fitch by means of the relevant material in the Required.
How your essay sheds light on the broader controversy : Closing remarks. End your argumentative essay with a paragraph of closing remarks. Provide some reflections of what you have attempted to achieve by means.
Which statements is true regarding georgia legal state : Mississippi in accordance with new PCS orders Ethan received. Which of the following statements is TRUE regarding Georgia's legal state of residency?
Find determinant using cramers rule : Write a MPI program where each rank sends a message to its right neighbour - Find Determinant using Cramer's Rule and Find the Deadlock

Reviews

Write a Review

Programming Languages Questions & Answers

  Assembly language program

Write a program called A2P1 to run in the LC-3 simulator. The program asks for the user to type in his or her UPI.

  Smallest and largest values in element floating-point array

Copy 11-elemts array source into first portion of 34-element array sourceCopy. Find out the smallest and largest values in 99-Element floating-point array data.

  What is the standard terminal symbol for a flowchart

What might be considered the seventh step of the programming process?

  Explaining graphics as user experience on web sites

Graphics provide significant richness to the user experience on web sites. Discuss how each of these sites uses graphics in good or poor ways.

  Calculate the power of any number a raised to the exponent n

Power.java which contain the details of creating the Power class and the method power which should calculate the power of any number a raised to the exponent n.

  Create a shell script that will list files in a directory

This option instructs the program to display a long listing. The output shall display the following column headers

  Calculates the total number of votes received by a candidate

Calculates the total number of votes received by a candidate - the function updateVotesByRegion (of the class candidateType) updates only the number of votes for a particular region.

  Write a program that uses a random number generator

Write a program that uses a random number generator to generate a two digit positive integer

  Small game development

Small game development - the development has to be done in PROLOG LANGUAGE.

  What are criteria for selection of a programming language

What are the criteria for selection of a programming language for developing Internet of things OR How to determine which programming language is suitable for developing Internet of things (IOT)

  Develop procedure to returns recent order information

Develop a procedure that returns the most recent order information for aparticular basket. This procedure must determine most recent stage entry from the BB_BASKETSTATUS table

  A text string using prompt

A text string, using prompt, either"valid name" or "invalid name",depending on whether the input names fit the required format, which is Last name, first name, middle initial

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd