Thread: Election Program

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    2

    Question Election Program

    Hi,

    I am a university student who has a C Programming assignment to make a program which searches and displays Election results from a text file. I DO NOT understand or know how to make this program and would really really appreciate some help...

    Website for Assignment

    I look forward to hearing from you soon

    Thanking you in advance

    Richard Angel

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Those requirements are appropriately vague, so unless the file is unusually large I would recommend using a linked list to hold the records in memory then you can move through them easily. Printing the output and only loading records that meet a certain condition is simple enough. I can offer clarification, but I'll need to know what exactly you don't understand.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    2
    thanks for your reply - basically i'm very confused about how to do any of the programming and how to put it all together. I know that i have to have a menu with a quit option, help file, and the option to view the next, previous, last and first records. I dont actually understand how to do any of this. If you could tell me what functions etc. i need to use to do different things and how to do them then that would be very appreciated. Thank you

    Richard

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >basically i'm very confused about how to do any of the
    >programming and how to put it all together
    You really shouldn't cut class, it's bad for the GPA.

    >I know that i have to have a menu with a quit option, help file,
    >and the option to view the next, previous, last and first records.
    The menu is very easy, most people prefer a switch statement that calls the appropriate functions:
    Code:
    while ( userSelection != ENDCASE ) {
      /* Print the menu and let 
      ** the user choose an option
      */
      switch ( userSelection )
      {
      case 1: function1(); break;
      case 2: function2(); break;
      .
      .
      case ENDCASE: continue;
      default: error(); break;
      }
    }
    The quit option simply continues the loop and causes the test to fail.

    A help file is also very simple, just create a text file that has all of the information in it and when the user chooses the option to view it, you open the file with fopen and print the contents to the screen.

    Viewing the next, previous, first, and last records is simple if your data structure is set up properly. Because this is homework, you can probably get away with using an array. However, to truly impress your teacher and make the program a bit more robust, you should use a double linked list with a head pointer and a tail pointer. This gives you ready access to the current record, the pervious and next records and also the first and last in the list. I won't give you the code for that because you can find it just about anywhere, and this is your assignment, not mine.

    Hopefully that helped.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM