+1-415-315-9853

info@mywordsolution.com

## Programming

 C/C++ Java DOT NET Python Assembly C Sharp Perl COBOL Visual Basic CAD/CAM Object Oriented Programming Asp.NET PHP JSP Shell Scripting Java Script Ajax CSS/HTML Joomla Wordpress Megento Photoshop DBMS PL-SQL Oracle MS-SQL MS-ACCESS My-SQL SYBASE FOXPRO Excel Programming Language Mobile Applications

Problem

Sorting is a frequent array operation.  An array can be sorted if there is an ordering relation between the elements in array.  For illustration, if the array comprises a set of integer elements, we can order the elements according to integer number line.  A common technique whereby the elements in an array might be sorted is called the bubble sort.  Supposing an array of positive integers which we wish to sort according to the sequence represented by integer number line, the bubble sort operates as follows:

1.  Find out the two adjacent elements, X and Y, in the array such that X > Y and swap X and Y, then sort the resulting array.

2.  If there is no adjacent pair of the elements, X and Y, in the array such that X > Y, the list is sorted.

Note that the reason of swapping two elements X and Y that occur out of order is so that after the swap, the new list is closer to a sorted list.  After a sufficient amount of swapping, we must end up with all the elements in order.  For illustration given the array:

{1 2 5 4 7 3 6 8 10 9}

We would commence by the finding elements 5 and 4 and swap them to get:

{1 2 4 5 7 3 6 8 10 9}

We would then continue as follows:

{1 2 4 5 7 3 6 8 10 9}
{1 2 4 5 3 7 6 8 10 9}
{1 2 4 3 5 7 6 8 10 9}
{1 2 3 4 5 7 6 8 10 9}
{1 2 3 4 5 6 7 8 10 9}
{1 2 3 4 5 6 7 8 9 10}

The procedure is known as a bubble sort since elements slowly bubble up to their correct location.

Implement and Design a Java program which sorts a 10 element integer array using bubble sort procedure.  The elements of the array to be sorted must be supplied by the user (assume the user will not input duplicates).

Make a GUI front end for your bubble sort program.  The result must look something like that presented in Figure.  You might use any graphic element to make your display - JOptionPanesare the easiest and most basic tools accessible to you, but you might also experiment with additional GUI controls such as JFrames, JPanels, etc.  I would advise you to use objects from the Swing library (those objects begin with 'J') as opposed to objects from AWT library - Swing objects are a little easier to use and are ultimately more flexible and robust than AWT objects.

In the illustration below, there are 10 text fields on a JFrame background to allow input of array elements (remember that for each text field you should press the carriage return key to invoke the listener).  When the array has been populated, we press the start button, at which point the given array is output as a label.  We then sort the output and result the sorted array.

Hint: Don’t attempt to make the GUI too sophisticated.  Just concentrate on producing a working result (although sound programming techniques should still be applied).

Figure: Bubble sort GUI (partial ex)

Remember to prepare the source code for each class in a separate file which should have the same name as the class name together with extension .java.  Remember also that by convention, class names commence with a capital letter.

Programming Language, Programming

• Category:- Programming Language
• Reference No.:- M91529

Have any Question?

## Related Questions in Programming Language

### Program assignment multi-threaded programming in java

Program Assignment: Multi-threaded Programming in Java Using Locks Objectives: To practice programming cooperating, synchronized multiple threads of execution. Description: In this programming assignment you will simulat ...

### Create a base class that will include the properties of

Create a base class that will include the properties of some type of data related to the company you work for or a favorite hobby. For example, I work for a healthcare provider, so my base class might be "Medical Facilit ...

### 1 design a class called complex the class enables

1) Design a class called Complex. The class enables operations on so called complex numbers. These are numbers of the form realPart + imaginary Part *i, where the i has the value 2) Design the class to have two private m ...

### Create a class rectangle with attributes length and width

Create a class Rectangle with attributes length and width, each of which defaults to 1. Provide methods that calculate the rectangle's perimeter and area. It has set and get methods for both length and width. The set met ...

### Assignmentpart 1 instance data and methods belong to

Assignment Part 1 Instance data and methods belong to objects (which are class members) and static data and methods belong to a class as a whole. Consider the real-life class named StatelnTheUnitedStates. Name some real- ...

### Programming logic and design questions1 given the

Programming Logic and Design Questions 1 given the following pseudocode module header: module calculate something (real x,real y, real z,) when the following call executes: call calculate something (21.6, 43.1, 15.2) sho ...

### Assignmentwrite a program that calculates the intersection

Assignment Write a program that calculates the intersection of two sets of numbers. The sets can be represented using arrays. The general idea is that A!=0 if i is in the set and A==0 if it is not. Array element A can th ...

### Computer science assignmnetuse this Computer Science Assignmnet use this program

Computer Science Assignmnet use this program http://snap.berkeley.edu/snapsource/snap.html# The assignment is to create a block to simulate coin tosses in snap. The block should take in 2 parameters, the number of coin t ...

### Assignment introduction to computer sciencepart a this

Assignment: Introduction to Computer Science Part A: This question is to be submitted to the instructor in the form of a Word (or OpenOffice) document containing the Java code and appropriate screen capture(s) of the out ...

### The car classdefine a class called car that implements the

The Car Class Define a class called "Car" that implements the parameterized Comparable interface. Each object of this class represents a type of car. Your class must provide all the methods in the public interface. Be su ...

• 13,132 Experts

## Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

### WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

### Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

### Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

### Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

### Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro