Implement the insertion sort algorithm

Assignment Help JAVA Programming
Reference no: EM132032086 , Length: 4 pages

Assignment

1. Introduction

In this assignment, you are to implement a console application that supports simple BMI (Body Mass Index) analysis functionality through a class called BMIAnalyser. A phased implementation approach is recommended; refer to Appendix 2 for further details.

2. The Application

The data to be analysed is to be loaded from 3 arrays containing person identifiers, heights (in metres) and weight (in kgs) using the loadFromTables() method provided in Appendix 1. Loading involves the creation of objects of type Record from each data triple (id[i], height[i], weight[i]). These are to be stored in an array of type Record called data. The size of this array is to be the same size as the data arrays. During loading, the BMI for each individual is calculated, using the following formula:

BMI = weight / (height*height)

where weight is in kilograms and height is in metres. The corresponding category is then determined as follows:

 

Category

BMI

(kg/m2)

 

from

to

Very severely underweight

 

15

Severely underweight

15

16

Underweight

16

18.5

Normal (healthy weight)

18.5

25

Overweight

25

30

Obese Class I (Moderately obese)

30

35

Obese Class II (Severely obese)

35

40

Obese Class III (Very severely obese)

40

 

This allocation is to be provided as a separate (private) method called classify() that is not provided in Appendix 1. The code for loading is provided in Appendix 1 as the method loadFromTables().

In order to facilitate search, data is to be maintained in ascending order of person id. Sorting is to be done after loading, using a method called sortById(). This method must implement the insertion sort algorithm. Note that loadFromTables() and sortById() are to be invoked from the constructor for the BMIAnalyser class

The application's View class is to execute (using a switch statement) the following command options:

1. Display the record for a specified person
2. Display records for all persons with BMI values within a specified range.
3. Display the minimum, maximum and average BMIs
4. Exit the application

As it is a console application, the user will need to be prompted to enter a command and its arguments (if any). My personal preference is for a minimal interaction scheme, as shown below:

run:
The following commands are recognised
Display this message > 0
Display a specific subject record: > 1 subjectID Display records for all subject records within a range > 2 bmi1 bmi2 Display statistics (minimum, maximum and average marks)> 3
Exit the application > 9
> 1 S01
<S01,1.8,80.0,24.7, Normal (healthy weight)>
>

Note that

1. Each command is designated a number
2. Command 1 requires a single argument - the subject id
3. Command 2 requires 2 arguments - the lower and upper bounds of a range of BMI values
4. I have added a "help" command (command 0)
5. The command options are displayed at the start of the application and whenever a "help" command is entered, rather than than after each command.
6. Records are displayed with no explanation of the fields

Feel free to adopt the above scheme or if you prefer, implement a more verbose interaction scheme.

For the commands that require arguments ( i.e. command 1 and command 2), note that

a. For commands 1 and 2, basic error checking is expected. For command 1, an error message is to be displayed if an id does not exist. For command 2, an error message is to be displayed if a member of the range is < 0 or > 100 or if the second member of a range is less than the first member.
b. For command 2, the range is exclusive of the values specified. Consequently, having both members of a range equal is to be flagged as an error.
c. For command 1, binary search is to be used.
d. For command 2, the results are to be stored in an ArrayList for display

The application must conform to the class diagram of Figure 1, although additional private members and methods are permitted.

1579_diagram.jpg

Figure 1. Class Diagram

Note that in Figure 1, the visibility of class methods and attributes are designated as + (public) and - (private). Associations are annotated with a label (for readability) and multiplicity. The multiplicity captures the number of object instances that can be involved in the association. In this case, only two values apply - 1 and *, which means many.

3. Submission
You are to submit a zipped folder containing

- The four .java files that comprise your application. Alternatively, if you have used NetBeans, this can be replaced with a zipped project folder. Details of how to do this are provided in the NetBeans FAQ on the unit website.

- Report.docx. This file contains a test report that includes student name, student ID number, unit name, unit code, a test plan and test results. The test plan is to contain a list of the input values that you have used to test the program, the expected output values and the actual output values generated by your program. The test results are screenshots to show that that the program generates the actual outputs shown in the test plan.

Attachment:- Assignment.rar

Reference no: EM132032086

Questions Cloud

What part of the speech is the attention step : What part of the speech is the attention step? Need step? Satisfaction? Visualization? Action appeal? Copy from the script and paste below.
What debt ratio should binomial use to calculate its wacc : What debt ratio should Binomial use to calculate its WACC?
What should carlos do about the transfer problem : Describe some of the things that Carlos might have done before, during, and after the training program to improve the transfer of training.
Calculate normalized earnings or cash flow : Calculate normalized earnings or cash flow as if these numbers are achieved instantaneously (i.e., realized at this very moment in time);
Implement the insertion sort algorithm : Display records for all persons with BMI values within a specified range - Display the minimum, maximum and average BMIs
Mutual funds represent a basket of diversified securities : Mutual funds represent a basket of diversified securities. Money Markets are a proxy for cash. Liquidity risk will most likely limit your availability to:
Distinguish between nominal and effective interest rates : On June 30, 2010, the company's fi scal closing date, when the bonds were being traded at 981/2, Distinguish between nominal and effective interest rates
What was your opinion on the piece : Did you provide a brief history of who the news outlet serves? In other words who is their audience? What was your opinion on the piece?
Research the forces that impact organizations : Research the forces that impact organizations, such as globalization and cultural diversity, technological advancements, and communication channels, etc.

Reviews

Write a Review

JAVA Programming Questions & Answers

  How are data structures managed and organized in language

How are data structures managed and organized in this language. How does the management or syntax of data structures in this language differ from how data structures are handled in other language

  Write a program that determines the day of the week

You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program.

  Reverse the array, and find the largest element

find the max block of an array by splitting it into three parts: left, middle, right. And then reverse the array, and find the largest element.

  Create a test application that creates a controller object

Create a test application that creates a controller object and play the game! Experiment with changing the game parameters and observe how the game reacts

  Determine how you will fix each type of error

Determine how you will fix each type of error. Be sure to clearly highlight the five steps within your posting - Using your text and/or the Internet as a resour

  Write a class encapsulating a pc-based game

Write a class encapsulating a PC-based game, which inherits from Game. A PC-bases game has the following additional attributes: the minimum megabytes of RAM needed to play the fame, the number of megabytes needed on the hard drive to install the fame..

  What are the tools available and limitations

You have found out that your team is not familiar with the Active Directory Tools. What are the tools available and limitations.

  Consider an array of integers

Consider an array of integers as below: int[] a = {5, 2, -4, 3, 0, -5, 7, 11, 6, 13} Complete the method named count(int[] a) in the class Count. The method should return the number of positive numbers in the array

  Implement two priority queues that provided priorityqueue

CPS 350: The main task is to implement two priority queues. All two implementations should implement the provided PriorityQueue interface (include implements PriorityQueue in your Java code).

  Create a frame-based application that displays an array

Include a TextField in the South. When the user clicks a button, the course name should display in the TextField

  Create an easy to read report layout for the daily report

Create an easy to read report layout (consistent spaces for each column and column headers) for the daily report (HINT: column headers you can use...auto info, price/discounted price, customer info)

  Write java program that demonstrates exception handling

You will write a Java program that demonstrates exception handling. Your program will accept from the user ten values and place those numbers in an array

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