Need Major Quick Help on Bubble Sort

I am trying to sort by year of birth and I enter it in as 1978, 1965, and 1947. All i want it to do is sort it to be 1947, 1965, 1978 yet it does 1965, 1947, 1978....any clues? it is the sortArray() method below. please respond immediately, i am trying to get this project done so i can go to bed to hand it in tomorrw, it's been bugging me for a week now and i just cant solve it
* A Database is a collection of persons (staff, student and faculty).
* A very simple database of people in a university. This class simply stores
* persons in an ArrayList and, at request, lists them on standard output.
* A first look at arrays.
* @author: Keitha Murray, James Devlin
* @version: January 2002, February 2002
public class Database
Person[] peopleArray = new Person[50];
Person[] tempArray = new Person[50];
int i;
int lastpos;
int nextpos;
* Create a new, empty person database.
public Database()
lastpos = 0;
nextpos = 0;
lastpos = nextpos - 1;
i = 0;
* Add a person to the database.
* @param aPerson the person to add
public void addPerson(Person aPerson)
peopleArray[nextpos] = aPerson;
lastpos = nextpos;
nextpos++;
* List all the persons currently in the database on standard out.
public void listAll()
for (int i = 0; i < nextpos; i++)
System.out.println(peopleArray.toString());
public void sortArray()
for (int j = 0; j < lastpos; j++)
for(int i = 0; i < lastpos; i++)
if (peopleArray[i].getYearOfBirth() > peopleArray[i + 1].getYearOfBirth())
tempArray[i] = peopleArray[i];
peopleArray[i] = peopleArray[i + 1];
peopleArray[i + 1] = tempArray[i];
lastpos--;
public void removeElement(String name)
int i = 0, position = -1;
int count;
boolean found = false;
while(i < nextpos && !found)
if (peopleArray[i].getName().equals(name))
position = i;
found = true;
i++;
count = i;
for (i = count; i < count - 1; i++)
peopleArray[i] = peopleArray[i + 1];

Hmm...
It still fails to compile for me, giving 5 exceptions. I get a compile-time exception for every time you try to use "peopleArray" as an element of the array (line #'s 48, 51, 52, 68, and 81). They look like this:
Database.java:81: incompatible types
found : Database.Person
required: Database.Person[]
peopleArray = peopleArray[i + 1];
, and:
Database.java:68: cannot resolve symbol
symbol : method getName ()
location: class Database.Person[]
if (peopleArray.getName().equals(name))
When I changed your sortArray() method as below the method performed properly:
public void sortArray()
  for (int j = 0; j < lastpos; j++)
    for(int i = 0; i < lastpos; i++)
      if (peopleArray[ i].getYearOfBirth() > peopleArray[i + 1].getYearOfBirth())
        Person temp = peopleArray[ i];
        peopleArray[ i] = peopleArray[i + 1];
        peopleArray[i + 1] = temp;
}The only differences are that all "peopleArray" references have been replaced by "peopleArray[ i]" and I removed the decrement statement.

Similar Messages

  • Need some quick help - fairly urgent!

    I've just taken over a new job and have been the task of finishing the new brochure for Christmas, there's not a lot to do but a lot of the measurements need changing
    This is the layout I'm dealing with..
    All the boxes have been made in Illustrator
    The text has been done in In'Design and it seems every piece of text is it's own box if that makes sense
    My question is, if I select the whole specification box - copy, paste it into Adobe Illustrator and change the text there, then paste the edited box back into In-Design, will I lose quality when it gets printed?
    I'm worried if I do it this way it may come out blurred? Or am I just worrying about nothing?

    I couldn't find an Illy file in the end and have ended up creating tables in ID to replicate what was already there!
    Didn't take very long and I guess if I didn't do it now, I'd come across the same situation next time!
    Date: Wed, 30 Nov 2011 08:48:07 -0700
    From: [email protected]
    To: [email protected]
    Subject: Need some quick help - fairly urgent!
        Re: Need some quick help - fairly urgent!
        created by Peter Spier in InDesign - View the full discussion
    There certainly are viable "quick fix" solutions proposed here, and if the dealine is looming and this file never needs to be touched again I might be tempted, but they are only postponing the pain for a file that needs periodic updates, and I wouldn't waste effort on them, myself, when that time can be put toward a proper rebuild now if that's the ultimate goal.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4054725#4054725
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4054725#4054725. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in InDesign by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Need a quick help on Pro*C

    Hi All,
    I need a quick help on Pro*C. Here's the details on the same:
    - My program takes one input file as parameter. Lets assume argv[2] is the name of the inputfile, which is my input parameter as well.
    - ps_filename = argv[2]; I'm copying argv[2] i.e. filename in a variable called ps_filename
    - Now this inputfile can be of two types, say type A_yyyymmddhhmmss.dat and B_yyyymmddhhmmss.dat.
    - Therefore for every run I'll have one of this value as input parameter which will be copied into the ps_filename.
    - Now I need to call two different functions based on the inputfile i.e. if ps_filename like 'A%' then call func A() else call func B();
    But in ProC/C there is no provision to use like operator.
    Therefore my question is how can I have ps_filename like 'A%' in C?
    Can anyone please help me to solve this issue?
    Hope to get your co-operation.
    Thanks & Regards,
    Debabrata

    debabratas wrote:
    Therefore my question is how can I have ps_filename like 'A%' in C?Hello, why don't you just substring on the first character, and if that's an 'A', then LIKE 'A%' will also hold.
    For example, in Pro*C:
    if (substr(ps_filename,1,1) == 'A') {
    ..

  • Need Some Quick Help w/Digital Frame for Xmas Gift Please...

    Have a Kodak digital picture frame. I don't understand the architecture of using the SD or USB cards w/the frame. I bought a 1 and 2-gb SD card. When copying my photos to the cards (112 of them), I get about 92 on the 1-gb card and it says full, but still shows most of the disk available, but also says is full so only about 92 photos goes on there. So I try the 2-gb SD card, and exactly the same amount of photos fit??? Why - it is twice as big??? I tried reformatting it to Macintosh but that only made the frame not recognize it, and when I formatted it back to MS-DOS, the frame still does not recognize it...Question one...Why the 1 and 2 gb SD cards hold only the same amount of pictures and how can I get it formatted back to be read by the camera...and can I fill 112 pictures on??? So then I thought maybe a USB stick would work. Bought a 2-gb Lenar Firefly stick and whoa and behold the exact same thing happens...I get about 92 pictures. So I figured which 92 pictures I wanted and selected all the card contents, moved to trash and deleted the pictures, then went back and picked only the 92 pictures I wanted and copied to stick and all show that they are there, but when I go to play them on the frame the old pictures I had on there before are there and not just the 92 new ones. How do I get rid of everything on the disk and get the pictures onto it that I want...I am afraid to erase or format it in any way because the frame probably won't recognize it again. Also, there is one picture that says "Bad file" and I have no idea which picture this is...and can't get rid of it because when I move them all to trash and put the new pictures on the stick that one is still there????? On the stick, I have like 130 MB (112 Pictures). When copied it says 92 pictures with 1.76 GB available...why is this and why can't I copy pictures to that space??? Can someone explain this to me and advise me what I can do, how do I reformat it so recognized also??? Also, I have songs copied to the frame's internal memory, but can't figure out how to play the pictures and also music at the same time????? Thanks so much for any quick help and thorough explanation so I can get this wrapped and sent. Merry Christmas! Gary

    I also have a Kodak picture frame and had the same problem with my SD card. Two things I learned.
    1-Even though you can't see them on the card - there are hidden files. You can see them - use this procedure.
    http://www.tech-recipes.com/rx/3104/os-x-show-hidden-files-and-folders-in-mac-os -x-finder/
    2-The other item I learned is that you must drag and drop the files and then empty your trash. While the reader is connected to the machine.
    Doing these two items will clear your card to full capacity.
    As far as the "bad file" I am still working on that one. I have little movie clips on my card and believe that may be causing this view..so your music may be causing this message. Start with just the pictures only and see if you can load them onto the frame.

  • Need major quicktime help

    I just purchased my mac book... It says I have "Quick Time Player 10" installed. I tried to install Quick Time 7 but it won't let me. I just purchased the Quick Time Pro upgrade because I need it to convert my WMV videos. There is no play to put in my registration code. I need help! I don't know what I'm doing wrong. In the end I need Quick time pro (which I just purchased). P.S. When I launch my quick time player no window appears... I don't know if that matter or not.

    Ok... So I installed quicktime 7 off of the disk that came with my mac. I already purchased quicktime pro and received a confirmation email and I'm trying to register it so I can start using it. I go to the quicktime pro registration and put in my name and my registration code... There is a button that says purchase quicktime pro (which I already did). There is no other options to select. How do I register it so I can download quicktime pro? Thanks for all of your help! I'm getting kind of frustrated because I feel like I'm not going to be able to get it onto my mac even though I already purchased it. Thanks again.

  • I'm new to java and I need some quick help with NetBeans.

    Hi. To whomever can help here's the problem. I've been trying to install netbeans ide 5.0 on my computer for a while now and i can't seem to find out what is wrong. I'm in a java programming course and i need the J2SE Developement Kit 5.0 Update 7 and NetBeans IDE 5.0 Installer on my comp. Whenever i go to install it, it can't automatically create a directory and has erroe null in place of it. Whenever i made a new directory for it a page would come up telling me all of the errors during the installation which are null. Since i have administrator privelages and plenty of free space on my hardrive.

    Hi,
    I want to suggest you that
    1.please check if any prerequisite is require before installing the NetBeans IDE,i hope there is nothing like that except proper jdk on your machine.
    2.if you already having JDK on your machine check for the compatibility of that jdk version with the required NetBeans IDE version.
    3.follow the steps provided to install the NetBeans IDE 5.0 for that refer the below link
    http://www.netbeans.org/community/releases/50/install.html
    hope you will get rid of the problem .....
    ---Vidya

  • Urgent Help with Bubble Sort

    alright the goal here is to sort the array by year of birth which is stored in a class elsewhere. but the problem lies in the IF statement:
    if (peopleArray[i] > peopleArray[i + 1])
    it says that the operator > cannot be applied, what does this mean and how can I fix it:
    WHOLE CODING:
    * A Database is a collection of persons (staff, student and faculty).
    * A very simple database of people in a university. This class simply stores
    * persons in an ArrayList and, at request, lists them on standard output.
    * A first look at arrays.
    * @author: Keitha Murray, James Devlin
    * @version: January 2002, February 2002
    public class Database
    Person[] peopleArray = new Person[50];
    int lastpos;
    int nextpos;
    int temp;
    int lastPosition;
    int nextFree;
    * Create a new, empty person database.
    public Database()
    lastpos = 0;
    nextpos = 0;
    lastPosition = nextFree - 1;
    * Add a person to the database.
    * @param aPerson the person to add
    public void addPerson(Person aPerson)
    peopleArray[nextpos] = aPerson;
    lastpos = nextpos;
    nextpos++;
    * List all the persons currently in the database on standard out.
    public void listAll ()
    for (int i = 0; i < nextpos; i++)
    System.out.println(peopleArray.toString());
    public void sortArray()
    for (int j = 0; j < lastPosition; j++)
    for (int i = 0; i < lastPosition; i++)
    if (peopleArray[i] > peopleArray[i + 1])
    temp = peopleArray[i];
    peopleArray[i] = peopleArray[i + 1];
    peopleArray[i + 1] = temp;

    I'm guessing there's a whole bunch of "[ i ]" characters not shown here because of the code tag so I'll ignore that issue.
    You can't compare an entire Person object using ">". You need to specify the field or method.
    e.g. if (peopleArray[ i ].getYear() > peopleArray[i + 1].getYear() ) {

  • Need some quick help with redoing a website

    Hi, I did my website done in iWeb in 2008, published it, and have it hosted by GoDaddy. I want to take it offline for now and design a new 'under construction' site, but there is a chance that I might want to still go back to the original version.
    I see the current 'Domain' in Home Folder>Library>Application Support>iWeb.
    Can I just redo my site (still working in pre-2008 iWeb), publish it, and if I need to, use the old 'Domain' to revert to my current website?
    If yes, how do I do that....and, if 'no', what should I do?
    Thanks!

    Hi and thanks. To reply....
    I published the website in iWeb and it is on my MobleMe. It was done in iWeb v 1.1.2, and I have not upgraded iLife on the computer that I designed the website on, as I feared losing some/all of it in an upgrade.
    I do, however, pay GoDaddy for my corporate URL AND hosting....which I suspect is the forwarding and not 'hosting' per se....but on my Hosting account on GoDaddy it does say 'Shared Hosting'.
    I do not want to 'overwrite' my current site just yet, as I am uncertain about the next one's content or the time to do it the way I envision it. What I want to do is SAVE my current site in case I want it back and, in the meantime, put up a page that says Under Construction. Can you help with that?
    Much appreciated

  • I need a quick help plz :(

    Ok i have a question and i tried to answer it but i still have a few errors..can someone please give me my code back with the correction plz ? :(.... and i need it in less then a day...i know am being pushy am so sorry but i really need it
    the Q is
    Consider a superclass PurchaseItem which models customer�s purchases. This class has:
    -     two private instance variables name (String) and unitPrice (double).
    -     One constructor to initialize the instance variables.
    -     A default constructor to initialize name to �no item�, and unitPrice to 0. use this()
    -     A method getPrice that returns the unitPrice.
    -     Accessor and mutator methods.
    -     A toString method to return the name of the item followed by @ symbol, then the unitPrice.
    Consider two subclasses WeighedItem and CountedItem. WeighedItem has an additional instance variable weight (double) in Kg while CountedItem has an additional variable quantity (int) both private.
    - Write an appropriate constructor for each of the classes making use of the constructor of the superclass in defining those of the subclasses.
    - Override getPrice method that returns the price of the purchasedItem based on its unit price and weight (WeighedItem), or quantity (CountedItem). Make use of getPrice of the superclass
    - Override also toString method for each class making use of the toString method of the superclass in defining those of the subclasses.
    toString should return something that can be printed on the receipt.
    For example
    Banana @ 3.00 1.37Kg 4.11 SR (in case of WeighedItem class)
    Pens @ 4.5 10 units 45 SR (in case of CountedItem class)
    Write an application class where you construct objects from the two subclasses and print them on the screen.
    and i wrote this program
    public class PurchaseItem {
         private String name ;
         private double unitprice;
         public PurchaseItem (String name , double unitprice) {
              this.name = name;
              this.uniteprice = unitprice;
         public PurchaseItem() {
              name = "no item" :
              uniteprice = o;
    public double getunitprice() {
         return uniteprice;
    public String getname() {
         return name;
    public void setName(String newName){
              this.name = newName;
    public void setuniteprice(double newuniteprice){
              this.uniteprice = newuniteprice;
    public String toString(){
         return "\nitem name:" + name + "@" + "\nuniteprice:" + uniteprice;
    public class WeighedItem extends PurchaseItem {
         private double kg;
         public WeighedItem(String name , double unitprice , double kg) {
         super (name , uniteprice);
         this.kg = kg;
         public double getunitprice() {
              return uniteprice + "" + kg;
    public String toString() {
         return "\nitem name:" + name + "@" +"\item weight:" + kg + "\nuniteprice:" + uniteprice;
    public class counteditem extends PurchaseItem {
         private int quantity;
         public counteditem(String name , double unitprice , int quantity) {
         super (name , uniteprice);
         this.quantity = quantity;
         public double getunitprice() {
              return uniteprice + "" + quantity;
    public String toString() {
         return "\nitem name:" + name + "@" +"\quantity:" + quantity + "\nuniteprice:" + uniteprice;
    i know i still miss the test class but that not important now i just wish someone will help me with the corrections of the above code PLZ
    thanx in advance :(

    When you post code, wrap it in [code] tags so we can read it.
    Also indent it sanely.
    If you can't compile, post the compiler error messages.
    If it runs but throws an exception, post the stack trace.
    If if runs without throwing an exception but you've foolishly written your code to silently catch exceptions, fix your code by actually printing the stack trace in the catch blocks, then rerun.
    If your code smartly reports exceptions, and it runs, but it still doesn't work, try adding some debugging code (displaying the values of various variables and showing when methods begin and end, for example) to help narrow down the problem. When you've narrowed down the problem, try writing a small, compilable program that exhibits the same problem. If you can't fix it with that, post the example program here.

  • Need MAJOR itunes help

    Ok...Never before had issues with itunes until the latest updates that go back to this past fall...I really have no idea how to use this program like I once did.
    here is what I need help with:
    1)  Bought an album on my iphone...cannot seem to find where to download it on any of my three macs (MBP, MM, imac).  In itunes on my MM it seems to exist in the cloud only, but there is an exclamation point to the left of each song.  I cannot find this album on any of my other two macs and cannot find an option to download it to these anywhere.
    2)  My music library is located on an external RAID drive.   In itunes preferences I always set this as the location of my itunes folder, but for some reasons it always defaults back to the itunes folder that is on the local HD.  WHy does it keep changing back?
    3)  Somehow I ended up with three different libaries.  There is a libaray with a little house icon with a musical note on it, than the RAID library, than some other library with chinese characters on it...I have no idea where this latter one came from...

    Just run the iPod updater. One of the choices is to restore it back to factory defaults. That should wipe the drive. Then you can run the updater again and install the latest version of software for your particular iPod.
    I had the same problem once before, and that took care of it, lickity split!
    Good luck,
    Mike

  • I need MAJOR ipod help!!!

    I just got a new iPod that's 120 GB because I was running low on disk space on my computer. So I added my entire music library which is about 8,000 songs, 50 videos, Photos and some IMPORTANT files to its drive. The iPod was working fine so I deleted all that music from my PC. Then suddenly yesterday the iPod froze so I tried to reboot it by holding center + menu. Now when I try to turn it on it asks me to connect it to the computer/iTunes. iTunes says I gotta restore it hence losing ALL my music, video and files I have stored there.
    Obviously I can't restore it or there goes all my music and videos. PLUS important files that I desperately need for work....
    I can't go into the iPod's hard drive because it says I gotta restore it when i try, so how do I get it to unlock it self from restore mode?!?!?!
    please help, I'm gonna go crazy because I can't lose these files that I stored in there. Not to mention I deleted all the music files from my computer, so basically I loose all my music because I always give away my Cd's. Please there's gotta be a way to reboot it without restoring the iPod and losing all the files.

    So I added my entire music library which is about 8,000 songs, 50 videos, Photos and some IMPORTANT files to its drive. The iPod was working fine so I deleted all that music from my PC....
    Bad move... You could so easily have your iPod lost, stolen, damaged or, as it is now, in need of restore. Thankfully there's reasonable scope for optimism in this last case.
    *Recover media from iPod*
    Check out this post from Zevoneer for some iPod media recovery options.
    http://discussions.apple.com/message.jspa?messageID=9935961#9935961
    Many of the recovery tools rely on the iPod having a valid library, which if it's in restore mode is unlikely. The manual method referred to in Zevoneer's post should work regardless.
    Depending on just how you put the pictures on the iPod you may be out of luck if you've deleted the orginals. Unless you included the option for "full resolution" images it will just have a libray of thumbnails. Some tools may recover these but the detail will be lost. If the originals have been put on the iPod iTunes will have assigned them names based on their dates rather than their original titles so you'll have to reconstruct these by hand.
    tt2

  • I NEED MAJOR QUICKTIME HELP.

    So here's what happened.
    I needed to go to a movie and my mom needed to record her concert (which was about 2 hours long). I open up quicktime and click on 'new movie recording' then leave it there, close the computer, and tell her: press the red button once to record, then press it again to stop.
    After the movie, we come home, I check the computer, only to find out that it only recorded 2 SECONDS, when it should've recorded the WHOLE 2 HOURS. I told my mom to hit the button once to record it, then once again to stop it, then to just close the computer and not to touch anything. Why did this happen, and is there any way to get the 2 hours back? They should've just loaded after the recording was stopped, shouldn't they have? Why did Quicktime do this? Does it not record movies more than 1 hour? HELP.
    This was her concert, and we're both upset that the recording was lost and that quicktime was acting like a piece of ****.
    HELP!

    While we all have MacBooks in this forum not all of us use QuickTime. There's a QuickTime Support Community where everybody uses QuickTime. You should also post this question there to increase your chances of getting an answer.  https://discussions.apple.com/community/mac_os/quicktime

  • New to the game and need some quick help

    I have been thrown our exisiting phone infrastructure and what do you know we are having some issues.
    We have a new series of DID's and when they are dialed from our directory they go anywhere? Not routing to the proper extension.  Translation pattern looks good in comparison to the extensions that are working.
    Cisco Unified CM Administration System version: 6.1.3.3000-1
    Cisco Application Administration - 5.0(2)_Build064
    Package: Unified CCX Enhanced
    Regards,
    Dan

    First thing to know is that everything that has a DN can be used for routing, so it's a good idea to look at the route plan report to find matches.
    If you can't find an exact match, chances are you're hitting something with wildcards ie X, [1-2], etc
    An easy way to check routing if you're new to the game is to use DNA
    Cisco Unified Communications Manager Dialed Number  Analyzer Guide, Release 6.1(1)
    http://www.cisco.com/en/US/docs/voice_ip_comm/cucm/dna/6_1_1/bw-dna.html
    HTH
    java
    If this helps, please rate
    www.cisco.com/go/pdihelpdesk

  • SQL Commands.Need a quick help.

    Hi Guyz,
    I need to know if the table spaces are auto extend or not.which command should i use.
    Thnx in advance
    Navneet Kaur

    Auto extent is turned on/off at datafile level, check
    select FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE from DBA_DATA_FILES;

  • Need a quick help!! Query hangs for hours

    Hi Guys,
    This is actually a stupid rollback query iam working on, for a one time load which is to be done this weekend.
    DELETE FROM OWNER.SBS_PYMT_FEE where CRE_USR_ID='';
    The actual problem, it takes hours to respond in QA and should take more time in PROD Considering the volume, it is doing a full table scan and our DBAs suggested Indexing on CRE_USR_ID would be a bad idea as the table is partitioned and is huge. CRE_USR_ID is the only column identified for 1 file.
    This is a one time activity.
    Any ideas or work arounds would help me a lot.
    And sadly, I do not have access to more stats.
    Thanks,
    Raj.

    I wondered about parallel settings because parallel_dml_mode is disabled by default:
    SELECT name, value, isdefault
    FROM   v$ses_optimizer_env
    WHERE  sid IN
           (  SELECT sid FROM v$mystat )
    AND    name LIKE 'parallel%'
    ORDER BY name;
    NAME                           VALUE                     ISD
    parallel_ddl_mode              enabled                   YES
    parallel_degree                0                         YES
    parallel_dml_mode              disabled                  YES
    parallel_execution_enabled     true                      YES
    parallel_query_default_dop     0                         YES
    parallel_query_mode            enabled                   YES
    parallel_threads_per_cpu       2                         YES
    7 rows selected.(example from 11g)
    Message was edited by:
    William Robertson

Maybe you are looking for

  • Why is that when I changed my plan to a family plan, it pushed my device upgrade back another full year?

    In November of last year, I added my mother to my plan and it changed us to a family plan. Judging by from when I bought my device, I should have an upgrade this March, but since we changed the plan, my device upgrade was pushed back until March 2015

  • Disk utility network hdd

    Anyone know if its possible to use Disk Utility to examine a External HDD connected to TC by ethernet (or USB). One of the volumes in the external HDD suddenly does not show up in the finder anymore. might be overful? I have the external HDD connecte

  • The music will not come off of my ipod

    I wanted to adjust the music on my ipod by taking some of it off and it just won't come off of my ipod.

  • Making Properties Panel reappear

    Hello, I cannot see the Properties Panel on my laptop anymore.  I was using the dual monitor mode with my laptop at work.  However when I try to use Xcelsius using only my laptop screen, the properties panel is not visible anymore.  Any help you can

  • Can I register Nano to two different computers?

    I bought my mother a 3rd gen 8gb Nano for Christmas. My ITunes library is huge. She has nothing. Could I register her iPod on my ITunes download a selection, and then do the same thing on her computer? I am thinking that the selection of music from m