Thread: Decidedly average homework problem

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    19

    Decidedly average homework problem

    Hey guyz this is gonna be my last question (THANKS IN ADVANCE):

    4. Display Data
    Write a function to read and display the contents of names and marks. You then ask the user for a name and using the linear search return the index to the user. If -1 is returned then the name is not in the file. Otherwise write out the name and mark for that student.
    Next, sort the arrays, write them out and then ask the user for a name to search for. This time use the binarySearch to return -1 or an index. Display the student’s name and mark if found.


    Code:
    void getNames(ifstream& inStream, string names[], int marks[], int numElts);
    int linearSearch(const string names[], int numElts,string who);
    int binarySearch(const string names[], int numElts,string who);
    void selectionSort(string names[], int marks[],int numElts);
    void displayData(const string names[], const int marks[], int numElts);
    int main()
    {
    	string names[NUM_NAMES];
    int marks[NUM_NAMES];
    	ifstream inStream;
    
    int index;
    	string searchWho;

    AND YEA GUYZ I WAS MISSING THE FOLLLOWING INFO ON THE LAST 4 QUESTIONS I PUT UP:

    File for names and marks:

    Collins Bill 80
    Smith Bart 75
    Allen Jim 82
    Griffin Jim 55
    Stamey Marty 90
    Rose Geri 78
    Taylor Terri 56
    Johnson Jill 77
    Allison Jeff 45
    Looney Joe 89
    Wolfe Bill 63
    James Jean 72
    Weaver Jim 77
    Pore Bob 91
    Rutherford Greg 42
    Javens Renee 74
    Harrison Rose 58
    Setzer Cathy 93
    Pike Gordon 48
    Holland Beth 79

  2. #2
    Registered User
    Join Date
    Nov 2009
    Posts
    82
    What's the question?

    That's not challenging either, this is a craptastically boring homework assignment at best. You're trolling, aren't you? I have this feeling... I can tell by the pixels.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    19
    the question is written at the top!

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    82
    I see statements and instructions, no questions.

    Questions sound like this;
    "What's wrong with these eggs? Why are they green?"

    That's when we tell you that it's because your mom added green food coloring! SUCCESS!
    Last edited by since; 12-03-2009 at 03:10 PM.

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    19
    kk i will write it again (and by the question i mean intructions that r given to write this program):


    4. Display Data
    Write a function to read and display the contents of names and marks. You then ask the user for a name and using the linear search return the index to the user. If -1 is returned then the name is not in the file. Otherwise write out the name and mark for that student.
    Next, sort the arrays, write them out and then ask the user for a name to search for. This time use the binarySearch to return -1 or an index. Display the student’s name and mark if found.

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    82
    Oh, by question you meant to follow the instructions. No.
    Do you have any questions that pertain to your attempts at writing the software?

    Is it just me or is this like the fourth time in the last couple days someone has tried to trick people here in to doing their work for them? It's insulting that beginning students think people are so stupid that they'll be tricked by 'I DARE YOU!'.

    Honestly, go to this website; http://www.rentacoder.com/RentACoder...t/default.aspx

    People will do your work for you there, and charge around $10-$50.
    Last edited by since; 12-03-2009 at 03:15 PM.

  7. #7
    Registered User
    Join Date
    Dec 2009
    Posts
    19
    i have no clue how to continue with this assignment. i need some1 to help me start on it. like give me some type of hints of how to go bout doing this thing. ty

    and wat do u mean by "I DARE U" i never said that...im just lookin for help.
    Last edited by kingkobra; 12-03-2009 at 03:17 PM.

  8. #8
    Registered User
    Join Date
    Nov 2009
    Posts
    82
    Learn what a function is, how it works, and how to write them.

    Then Google each of those search methods and learn them, then write the code.

    There's a lot of pieces to this, and if you don't know C++ and took this assignment then you have a lot more problems. You need to learn C++, and write some simple programs and work up from there.

    cprogramming.com
    cplusplus.com

  9. #9
    Registered User
    Join Date
    Dec 2009
    Posts
    19
    i totaly get ur point....i do understand this language....i just need help with recrusion...plz help me and stop giving me stupid advices...if u dont wanna help then plz let others help me(with all due respect)...ty

  10. #10
    Registered User
    Join Date
    Dec 2009
    Posts
    19
    cmon u guyz......i no u all know how to do this problem......dont listen to since....he is a bad person.....just help me out....im just asking for a few clues......ty

  11. #11
    Registered User
    Join Date
    Nov 2009
    Posts
    82
    Here, let me google that for you.
    c++ binarySearch - Google Search

    C++ Notes: Algorithms: Binary Search

    Wow look, tons of source code, look how bad I am, I'm so bad I'm going to give you the answer so you don't learn anything. What's ironic is you'll interpret that as a joke.

    You're just saying you can't do it, I'm willing to bet you haven't actually begun writing a program to even try putting the pieces together. If you're being given tests and assignments on algorithms you must have learning material given to you by a teacher, unless the assignment is to learn how to use Google. Honestly, I know I sound like an ass but are you understanding what I'm saying? People don't want to do others work for them. I know how mean and evil that seems, but few things are ever as they seem to be.
    Last edited by since; 12-03-2009 at 03:43 PM.

  12. #12
    Registered User
    Join Date
    Dec 2009
    Posts
    19

    Wink the end

    u little (cin << insert insulting word here)............ all i wanted was some help from YOU. if i wanted help from the internet, i would have gone there first. Now, you've proved that these forums are useless and all of u guys are pansies looking from some attention. Good luck in life, loser.

  13. #13
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    > i just need help with recrusion...

    Recursion is just a function designed to call itself. For example, the trick to a working binary search is that you have to make the search space smaller with every call, and to do that appropriately, you exclude half of it every time.

    So the algorithm is something like this:
    1. Find the midpoint
    2. Check if the midpoint is the item
    2a. If it is, you're done.
    2b. If it isn't and there's more than two items, split the list by the midpoint On the other hand, if you've reduced the list and haven't found the item, the search failed.
    3. Search the new list from step 1.

    The search space needs to be sorted (ascending or descending) for the binary search to work, because again the point is to ignore half the search space every pass. Anyway, for a recursive function to be considered working, it has to know when to stop, and that is step 2 of my explanation.

    And make sure your version works with a search space of 2 items.

  14. #14
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Code:
    u little (cin << insert insulting word here)
    The irony...she BURNS!!!!

  15. #15
    Registered User
    Join Date
    Aug 2009
    Posts
    198
    It's supposed to be cout!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calcuate average test grade problem
    By syrup890 in forum C++ Programming
    Replies: 3
    Last Post: 11-15-2008, 01:02 AM
  2. Question About My Homework Pls Help Me İmmediately
    By jennyyyy in forum C Programming
    Replies: 27
    Last Post: 03-13-2008, 11:40 AM
  3. A homework problem about C++ (Pointer)
    By joenching in forum C++ Programming
    Replies: 10
    Last Post: 03-14-2005, 04:28 PM
  4. Problem calculating average with "for"...
    By davidvoyage200 in forum C++ Programming
    Replies: 3
    Last Post: 10-25-2002, 10:02 AM
  5. homework problem
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 08-09-2002, 07:12 PM