Tools Inventory Program - IT 215 Java Programming Week 6 Checkpoint Inventory Program Part 3 import java.util.Scanner Program uses class Scanner to

Tools Inventory Program - IT 215 Java Programming Week 6...

This preview shows page 1 - 2 out of 4 pages.

/* * IT 215 - Java Programming Week 6 * Checkpoint: Inventory Program Part 3 */ import java.util.Scanner; // Program uses class Scanner to accept user input import java.text.NumberFormat; // Program Uses Class NumberFormat to format number output import java.util.Locale; // Program Needs to Use U.S. Currency //TootsInventoryClass public class ToolsInventoryProgram { final int MAX = 5; ToolsExtended pt[] = new ToolsExtended[MAX]; int numberOfTools = 0; //this method sorts the array accoding to the names (Sorting technique: Bubble Sort) public void arraySort(int count) { int pass , i; int temp; ToolsExtended s = null; //start sorting if we have more than 1 individual record in array if(count > 1) { //make count - 1 passes through the array for(pass=1; pass<count; pass++) { //in each pass shift largest element to right most position for(i=0; i<count-pass; i++) { //comparing the names of Individuals temp = (pt[i].getName()).compareTo(pt[i+1].getName()); if( temp > 0) { //if name at i position of array is greater than one at i+1 position than swap s = pt[i]; pt[i] = pt[i+1]; pt[i+1] = s; }//if ends }//second for loop ends }//first for loop ends }//if condition ends }
Image of page 1
Image of page 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture