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()----------------------------*/