4 Replies - 906 Views - Last Post: 28 January 2016 - 01:37 PM Rate Topic: -----

#1 samtheisen   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-January 16

I need help with a database sorting project in Java programming

Posted 27 January 2016 - 08:28 PM

Hey I just need some help creating program for a school assignment. It just involves some sorting from a small database. The code is relatively easy but I don't have much experience. If someone could write the code for me or at the very least help me write it that would be awesome. I can use java script or eclipse it doesn't matter. Below is the rubric for the assignment. I do need it for tomorrow so the sooner the better. I would show the progress I have made so far but I didn't take the save file home.Thanks, Sam

Rubric:

-View Alphabetical list by last name
-View list sorted by name of city
-view list sorted by zip code

(the data can be built into the program so you don't need to enter it upon running it)

Names: Address: City:
Barney Fife------10 Warbler Rd.----------Mountainville, SC 34765
William Clinton--1600 Pennsylvania Ave.--Washington, DC 44623
Cruella Deville--123 Witchey Way---------Hollywood Ca 12345
Sally Smith------3862 Street Blvd.-------Springfield, IL 31733
Marsha Brady-----1970 Groovy Street------Arlington, VA 51266
Gomez Addams-----1 Spooky Circle---------Tombstone, AZ 63341
John Adams-------3445 President Plaza----New York, NY 11220
Marie Antoinette-2 Rue Morgue------------New Orleans, LA 25993
Albert Einstein--7 Relativity Rd.--------Topeka KS 63121
Mick Jagger------100 Rolling Stone Path--Seattle, WA 23733
Mickey Mouse-----2 Disney Lane-----------Orlando, FL 72272






Here is what code I have so far. I can only figure out how to sort the names.


package datasorting;

public class datasorting {

	
    String[ ] names = {"Barney Fife", "William Clinton", "Cruella Deville", "Sally Smith", "Marsha Brady", "Gomez Addams", "John Adams", "Marie Antoinette", "Albert Einstein", "Mick Jagger", "Mickey Mouse"};
    sortStringBubble (names);
    for ( int k = 0;  k < 4;  k++ )
       System.out.println( names [ k ] );
}

public static void sortStringBubble( String  x [ ] )
{
   int j;
   boolean flag = true;  // will determine when the sort is finished
   String temp;

   while ( flag )
   {
         flag = false;
         for ( j = 0;  j < x.length - 1;  j++ )
         {
                 if ( x [ j ].compareToIgnoreCase( x [ j+1 ] ) > 0 )
                 {                                             // ascending sort
                             temp = x [ j ];
                             x [ j ] = x [ j+1];     // swapping
                             x [ j+1] = temp;
                             flag = true;
                  }
          }
   }
}
}


This post has been edited by macosxnerd101: 27 January 2016 - 09:20 PM
Reason for edit:: Renamed title to reflect the language. Java != JavaScript. Also, post your code *between* the code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: I need help with a database sorting project in Java programming

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: I need help with a database sorting project in Java programming

Posted 27 January 2016 - 09:22 PM

Quote

If someone could write the code for me or at the very least help me write it that would be awesome.

Please be cognizant of the rules. Nobody will write the code for you.

I would encourage you to adopt an object-oriented approach. My tutorial Moving Away From Parallel Arrays is a good place to start.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: I need help with a database sorting project in Java programming

Posted 27 January 2016 - 10:29 PM

Why would you so casually ask someone to complete your school assignment for you? That's very disappointing.
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher   User is offline

  • Enterprise Software Architect
  • member icon

Reputation: 3215
  • View blog
  • Posts: 12,098
  • Joined: 03-December 12

Re: I need help with a database sorting project in Java programming

Posted 28 January 2016 - 01:27 PM

Create a class for the objects you have with their properties. Viola!

Quote

I can use java script or eclipse it doesn't matter


This makes me think you really were not paying attention in class. As I don't think you know what the differences are in what those are.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: I need help with a database sorting project in Java programming

Posted 28 January 2016 - 01:37 PM

Cross-posted here
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1