Thread: C menu driven program

  1. #1
    Unregistered
    Guest

    Question C menu driven program

    hi, i am a student trying to learn how to program in C.
    our teacher has set us this project and i havent a clue where to start. Any help would be much appreciated. it is based on an election database file showing winning votes and parties involved across the uk.
    the program must do the following:-

    1)display records on screen one at a time and select first, last, next previous from a data file. this should use gotoxy to display the menu.

    2) 1 or 2 of the menu options must provide batch reports to process the data file and generate some summary info.

    3) the program will stay running until the user selects the option to quit.

    4) the program must be able to conditionally load or reload records from the data file.

    5) the program must have a help screen.

    6) insert and delete records must be supported.

    i have started this assignment by looking at functional requirements etc and have come up with these fields:-

    constituency - char -
    turnout - float
    type- char
    date - char
    winner - char
    party = c - char
    voting pop - int
    winning vote - int

    i have some code also this is the main file, i will also have an include file, a help file etc.

    # include < stdio.h>
    # include <conio.h>
    # include <string.h>
    # include <ctype.h>
    # pragma hdrstop
    #include “ Includefile.h” /* My include file */

    int main ()
    {
    int doReport1(void); /* Current query */
    char usrInput [MAXKB_LEN+1]; /* keyboard entry */
    int cont; /* for while loop */

    /* Set screen, row and columns */

    textmode (BW80); highvideo();
    textcolor( );
    textbackground( );
    clrscr ();
    cont = OK;

    /* End of inititalising */

    while (cont == OK)
    {
    gotoxy (15,10);
    cprintf (“Election file menu”);
    gotoxy (10,11);
    cprintf (“ R)un Record”);
    gotoxy (10,12);
    cprintf (“N)ext Record”);
    gotoxy (10,13);
    cprintf (“P)revious Record”);
    gotoxy (10,14);
    cprintf (“F)irst Record”)
    gotoxy (10,15);
    cprintf (“L)ast Record”);
    gotoxy (10,16);
    cprintf (“H)elp file”);
    gotoxy (10,17);
    cprintf (“Quit?”);

    /* Get input from user using switch case statement */

    gets(usrInput_Str);
    printf (“ please pick an option”);
    char reply;
    switch (toupper(usrInput_Str [0] ) )
    {
    case ‘Q’: /* User entered Q so it quits, prompt asking if you are sure about quiting */
    printf (“Are you sure you want to quit(y/n)?”);
    reply = getchar();
    while(reply== ’y’ || reply ==’Y’);
    cont=NOTOK;
    break;
    case ‘R’: /* User entered R to view reports */
    doReport1();
    clrscr();
    break;
    case ‘H’: /* User entered H to view help file */
    clrscr();
    break;



    case ‘N’: /* User entered N for next record */
    selectNext ();
    break;
    case’P’: /* User entered P for previous record */
    selectPrevious ();
    break;
    case’F’: /* User entered F for first record */
    selectFirst(); printf (“ Back to the beginning”);
    break;
    case ‘L’: /*User entered L for last record */
    selectLast(); printf (“Go to the end”);
    break;
    default: printf (“ Incorrect entry, please retry” );
    } /* -------------------End of switch case---------------------*/

    } /* -------------------End of while loop----------------------*/

    return (0);

    } /* -------------------End of main()----------------------------*/

  2. #2
    Registered User foniks munkee's Avatar
    Join Date
    Nov 2001
    Posts
    343
    1)display records on screen one at a time and select first, last, next previous from a data file. this should use gotoxy to display the menu.
    I have to ask - did the project requirements actually say that you must use gotoxy?

    Could you chuck some code tags on this - makes it easier to read.
    "Queen and huntress, chaste and fair,
    Now the sun is laid to sleep,
    Seated in thy silver chair,
    State in wonted manner keep."

  3. #3
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    gotoxy (15,10);
    cprintf (“Election file menu”);
    This could replaced with:


    Code:
    printf("Election file menu\n");
    That's only if it meets the project requirements though.
    The world is waiting. I must leave you now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  3. menu driven interface
    By weegi in forum C Programming
    Replies: 4
    Last Post: 04-17-2004, 04:08 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. c++ program with a button menu
    By quakegod in forum C++ Programming
    Replies: 0
    Last Post: 01-07-2002, 01:09 AM