Project Help please!

This is a discussion on Project Help please! within the C++ Programming forums, part of the General Programming Boards category; This is my project that is due later tonight. I have been trying to figure out what i am suppose ...

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    3

    Project Help please!

    This is my project that is due later tonight. I have been trying to figure out what i am suppose to be doing for this project. Got any hints that would be grateful.

    Here is what i started trying to do. I have been trying to create a file called "friendsType.h". however i can't get this to work in any way and same thing when i tried to format the "struct nodType".

    Again if you can help me get started that would be great. thanks

    Below is the project that i am doing.




    This project requires you to write a C++ program that will manipulate data stored in a self-organizing linked list. A self –organizing list moves frequently used entries to the beginning of the list. This program will give you practice inputting data from files, writing and calling functions, using a linked list, and outputting data to a file. You should only use one linked list.

    The infotype in this problem will consist of a name (string), a phone number (string) and a counter (int). Whenever a phone number is looked up, one is added to the counter for that node.

    Datafile “friends.txt” contains lines of the following format:
    <name> <phone number >
    Data items are separated by blanks.

    Each line of file “Lookup.txt” contains a name.

    Store the data from file “friends.txt” in a linked list using pointers. The order of items in the list should be the same as the order in the file. After the list is created, print out the linked list.

    For each entry from “Lookup.txt”, search the linked list for the input name. Print to the screen the name and phone number. Print a message for names that are not found. In addition, increment the counter in the node. If the counter in a node becomes 3, reset the counter to zero and move that entry to the beginning of the list.


    After all entries from “Lookup.txt” are processed, print out the list of names, phone numbers and counters to the screen. Also, create an output file containing the list of names, phone numbers, and counters.


    Notes: Work incrementally!
    1. Remember to review the grading algorithm.
    2. Save a copy of the file you hand in. Make sure to leave the file unchanged after your submission until you receive a grade on the project assignment.
    3.The data file should be error free- let me know if you find errors in the sample data
    4. Do not use global variables.
    6. You should use functions to accomplish each task. Use function prototypes. Declare the main function before you declare additional functions.
    7 Print an error message if the either input file is missing.


    Friends.txt

    Brite,Brenda 410-123-4567
    Carpenter,Candace 410-123-4444
    Delray,Don 410-123-5555
    Ellis,Ellen 410-123-9876
    Fink,Fred 410-123-8765
    Popular,Pat 410-123-6666
    Jenkins,Jan 337-471-1111
    Hacker,Harry 888-123-3333
    Hacker,Horatio 888-321-6543
    Hacker,Henry 888-321-6544
    Hacker,Henrietta 888-321-6545
    Hacker,Hillary 888-321-6543
    Zappa,Zeke 888-345-5555
    Kruella,Karen 888-345-9999
    Martens,Max 800-234-7777
    Rabbitz,Lucky 999-333-1111
    Overton,Oscar 410-471-2222
    Wallace,Wally 888-555-5656
    Hacker,Hortense 888-321-6546
    Yodler,Yancy 410-742-8888
    Miles,Morticia 410-543-0444


    lookup.txt

    Popular,Pat
    Hacker,Harry
    Popular,Pat
    Fink,Fred
    Zappa,Zeke
    Hacker,Harry
    Brite,Brenda
    Popular,Pat
    Delray,Don
    Delray,Don
    Popular,Pat
    Zappa,Zeke
    Wallace,Wally
    Popular,Pat
    Kruella,Karen
    Brite,Brenda
    Kruella,Karen
    Hacker,Harry
    Brite,Brenda
    Missin,Marvin
    Kruella,Karen
    Popular,Pat
    Brite,Brenda
    Hacker,Harry
    Findem,Kenya
    Hacker,Henrietta

  2. #2
    Registered User
    Join Date
    May 2007
    Posts
    147
    black_hole (great name choice, BTW).

    You're likely to get a torrent of unflattering replies with warnings about how members don't start other's homework around here.

    Posting a request like this without a start isn't a way to get anyone to respond with much else.

    Impress us with how lost your are by giving us something to HELP with.

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    3
    well thanks for the comment on the name.

    I know that this sight works were know one is suppose to start/do/finish someone's homework. However, that is why i was asking for hunts since i have been working on it.

    Though ill post what i got in a little bit once i get it organize and not just a bunch bunched up and confusing.

  4. #4
    Registered User
    Join Date
    Apr 2009
    Posts
    3
    This is what i have going so far.


    #include <iostream>
    #include <fstream>
    #include <string>
    #include <iomanip>

    using namespace std;


    struct friendType
    {
    string name;
    string phoneNumber;
    int count;
    };


    typedef friendType infoType ;

    struct nodeType
    {
    infoType info;
    nodeType *link;
    };




    void print(nodeType *);
    nodeType * makeIt (ifstream& inFile);

    friendType getOne ( ifstream& dataIn );
    void printOne ( friendType one) ;


    int main ()
    {

    string name;
    string phoneNumber;
    int count = 0;



    cout << " Poject Description: This project requires you to " << endl;
    cout << " write a C++ program that will manipulate data " << endl;
    cout << " stored in a self-organizing linked list. A self" << endl;
    cout << " -organizing list moves frequently used entries to"<< endl;
    cout << " the beginning of the list. This program will give" << endl;
    cout << " you practice inputting data from files, writing and"<< endl;
    cout << " calling functions, using a linked list, and " << endl;
    cout << " outputting data to a file. You should only use one"<< endl;
    cout << " linked list." << endl << endl << endl;





    nodeType *list, *box;


    ifstream dataFile;

    dataFile.open ( "friends.txt");
    if (!dataFile )
    {
    cout << " file not found ";
    system ( "pause");
    return 1;
    }

    list = makeIt (dataFile);
    print ( list);



    system ("pause");
    return 0;
    }




    nodeType * makeIt (ifstream& inFile)

    {
    nodeType * first, *last, *temp;
    infoType x;

    first = NULL;

    x = getOne (inFile ) ;
    while (inFile)
    {
    temp = new nodeType;
    temp->info = x;
    temp->link = NULL;

    if ( first == NULL )
    {
    first = temp;
    last = temp;
    }
    else
    {
    last->link = temp;
    last = temp;
    }

    x = getOne (inFile ) ;
    }

    return first ;

    }

    void print(nodeType *first)


    nodeType *current;
    current = first;

    while (current != NULL)
    {
    printOne ( current->info) ;
    cout << endl;
    current = current->link;
    }
    cout << endl;

    }




    friendType getOne ( ifstream& dataIn )
    {
    friendType one;


    dataIn >> one.name >> one.phoneNumber;


    return one;
    }



    void printOne ( friendType one)
    {
    cout << fixed << showpoint << setprecision (2);
    cout << "Name: " <<one.name << endl;
    cout << "Phone Number: " << one.phoneNumber << endl;

    }

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Step 1: Use code tags
    Step 2: Tell us what isn't working with your code, or tell us what parts you are having trouble implementing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 10:05 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 02:30 PM
  3. Dynamic Binding
    By gpr1me in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2006, 09:01 AM
  4. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 08:41 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21