Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

programming help required

Options
  • 07-11-2009 3:24pm
    #1
    Registered Users Posts: 3,599 ✭✭✭


    This post has been deleted.


Comments

  • Registered Users Posts: 116 ✭✭sean_84


    This post has been deleted.

    It's strange that you would be given this task before learning about arrays. Anyway, the solution will depend greatly on the programming language you are using? I'd advise you to look at tutorials for that language which cover creating and manipulating arrays. Bubble sort is a very simple algorithm for sorting data. Basically you just go through the array multiple times, comparing two adjacent elements at a time. If they are not in the right order, you swap them. When you go through the whole array without making any swaps, then you know the data is sorted.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Well these are parallel arrays.

    So you can progress through each by simply having one loop:

    [php]
    for (int i = 0; i < numElements; i++)
    {
    char initial = initialArray;
    char lastname = lastnameArray;
    double salary = salaryArray;
    }[/php]

    You'll have to check up bubble sort algorithm (Lots on this) and when you bubble a salary elements, you also have to buble the others as well so the arrays stay sync.

    I agree though, it's a tough one if you haven't touched arrays or sorting algorithms yet.


  • Closed Accounts Posts: 1,397 ✭✭✭Herbal Deity


    This post has been deleted.
    :'(


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    There isn't much to bubble sort once you think of what it is doing logically.


  • Registered Users Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Advertisement
  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    It's a sort that keeps bubbling numbers along until you reach a stage where the list is sorted either ascending or descending order. Have a good read of this: http://en.wikipedia.org/wiki/Bubble_sort


  • Registered Users Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    What language are you working on?

    There is Pseudocode on that too so you should give an attempt of transforming it to the language you using.


  • Registered Users Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Pseudocode is not a language, it's just general way of describing algorithms - no set way. What kind of lecturer do you have? - he doesn't sound good to me if he throwing you this sort of assignment without explaining a thing.


  • Advertisement
  • Registered Users Posts: 40,038 ✭✭✭✭Sparks


    This should be required reading... (actually, it is...)


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    :)


  • Registered Users Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Calm down :pac:

    I think he was getting at that you must google things. Googling bubble sort and algorithms isn't that hard ;)


  • Registered Users Posts: 40,038 ✭✭✭✭Sparks


    This post has been deleted.
    The point is, do some work on your own first, then show that work and then ask questions. And no, "I'm totally lost!" is not a question. I mean, if it was something really complex, like some sort of arcane algorithm like Duff's device, that'd be different, but this is pretty basic stuff.


  • Registered Users Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Registered Users Posts: 981 ✭✭✭fasty


    So do you want us to do the work for you?


  • Closed Accounts Posts: 1,397 ✭✭✭Herbal Deity


    This post has been deleted.
    Why are you doing the course if you don't want to?

    There's no problem asking for help if you've actually tried to understand what you're learning and you ask specific questions based on what you're having trouble with. Making spiteful posts about hating programming and essentially asking us to do your homework for you is not the right way to go about it.
    This post has been deleted.
    I'm guessing you're doing some kind of business/accounting degree and basic programming is a module in it. So you don't particularly like it? My advice is to suck it up, take some kind of interest and apply yourself to it.

    We can't all be good at everything, but we can all be average at anything we want to as long as we're prepared to apply ourselves and not just moan when we find ourselves having to do things we don't particularly want to do.

    Now, please post an attempt at this problem or ask specific questions, or you won't get any help on here.


  • Registered Users Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Registered Users Posts: 1,916 ✭✭✭ronivek


    How about you write a description in English of how you would go about the task and just ignore the programming language syntax and constructs in the first instance?

    So imagine lotto balls with the info on them lined up on a table and describe the steps you would perform in order to sort them into the order your assignment wants them in.

    Then translate that into general programming constructs; so for example:
    look at the first two balls on the table
    while my list isn't sorted yet I should repeat the following actions:
        if the second ball is greater than the first ball 
            then i should swap the two balls
        look at the next two balls on the table
    

    It might be easier to then translate your English description into Java code that way.

    Just a suggestion.


  • Advertisement
  • Registered Users Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Registered Users Posts: 2,534 ✭✭✭FruitLover


    This post has been deleted.

    These values aren't doubles (nor are any of the other values you've been told to use) - make sure you know what a 'double' is first of all, and why a letter of the alphabet isn't one (and then, determine what kind of array you should be declaring).

    You have unneeded input sections in your code (and they're not actually doing anything anyway). The question doesn't explicitly say you have to take input, so you can probably get away with declaring all three arrays yourself in the code, rather than reading them from input (confirm this with your lecturer though). In fact, there is a lot of stuff in there that either doesn't do anything or doesn't make sense at all. There shouldn't be any code in there that you don't know the results of (i.e. make sure you know what each line is actually doing).

    Have you tried ronivek's suggestion above? It's very important to have laid out exactly what you're trying to do before you start writing actual program code; otherwise you end up with a mess of random stuff like you have there.


  • Registered Users Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Closed Accounts Posts: 5,096 ✭✭✭--amadeus--


    With the greatest of respect I think you are attempting to run before you can walk.

    Have a read through something like this to get a fuller picture of variable types, control structures and teh like. You wouldn't write a story in French before you learned what the words meant nor can you write a program until you understand it's fundamentals.

    If you don't know the difference between (for example) a string and an integer then bluffing through this exercise with our help will be counter productive since you'll just be even more confused when you get onto more advanced topics.


Advertisement