Loading...
SCE
Home
AI Assistant
Ask Anything
Categories
Python
C#
C++
C
Visual Basic
Java
JavaScript
HTML
CSS
SQL
Git
VIEW ALL
Other
Tags
What's Hot
Featured
I'm Feeling Lucky
Latest
SCE
Loading...
Sign Up
Log In
Computer Science SBA (Sample)
Posted by
JanWan
Last Updated:
March 08, 2013
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
void create();
void new_member(FILE *);
void existing_member(FILE *);
void exit_program(void);
void welcomescreen(void);
void mainmenu(void);
int GetPassword();
void deletemember(FILE *);
int count = 3;
char password[10];//the password will be contained in here
typedef struct
{
int mem;
char l_name[15];
char f_name[15];
char add_ress[30];
int telephone_number;
char lname[15];
char fname[15];
int telephonenumber;
char address[30];
char plan[10];
int amt_paid;
int balance;
}newmember;
FILE *russian;
void main()
{
int PasswordCorrect;
printf("%s\n",__DATE__);//tells the time
printf("%s\n",__TIME__);//tells the date
welcomescreen();
if(PasswordCorrect == 0)
system("cls");//clears the screen
mainmenu();//contibue the program
}
//********************************************************************************************
void welcomescreen( void )
{
system("color 40");//change the words to and background to
system("cls");//clears the screen
printf("%s\n",__TIME__);//tells the time
printf("%s",__DATE__);//tells the date
printf("\n\n\n\n\t#################################################################");
printf("\n\n\n\t@\t\t\t WELCOME TO\t\t\t\t@");
printf("\n\n\n\t@\t\t\t EGAS DATABASE \t\t\t@");
printf("\n\n\n\t@\t\t MANAGEMENT SYSTEM \t\t@");
printf("\n\n\n\t@\t\t DONE BY: FABIAN GILL \t\t\t@");
printf("\n\n\n\t#################################################################\n\n\t\t\t");
GetPassword();
}
int GetPassword()
{
int count;
char password[20]; /*the correct password for the system*/
for(count=3;count!=-1;count--){//test the amount of time the password is entered
printf("\n\t\t\t\tEnter password:- ");
scanf("%s",&password);//user input
if(strcmp(password,"cybertech")==0){//test if password is correct
system("cls");//clears the screen
mainmenu();//continue the program
}else{//if password is incorrect
printf("\n\t\t\t\t Wrong Password\n");
printf("\n\t\t\tYou have %d more times to enter password\n\n\n\t\t",count);
system("PAUSE");//allows the user to see what is on the screen before the screen is cleared
system("cls");//clears the sreen
}//end of else
}//end of for loop
printf("\n\t\t\tYou have no more tries!\n\n");
getch();//if the tries are over then this is displayed
exit(0);//exits the program
}
//****************************************************************************************
void mainmenu()
{//beginning of option function
int cross;
system("color 04");
printf("\n\t\t\t\t\t*MAIN MENU*\n");
printf("\n\t\t######################################################\n");
printf("\t\t\tPlease select one of the following option:\n\n");
printf("\t\t\tPress 1 to Create New Member.\n");
printf("\t\t\tPress 2 to View Existing Member.\n");
printf("\t\t\tPress 3 to Delete Member File.\n");
printf("\t\t\tPress 4 to log off.\n");
printf("\t\t\tPress 5 to exit program.\n");
printf("\n\t\t######################################################\n");
printf("\nOption:");
scanf("%d",&cross);//user inputs
switch(cross){//beginning of switch statement
case 1: new_member(russian);//if 1 is entered go to new_member function
break;//end of case 1
case 2: existing_member(russian);//if 2 is entered go to existing member function
break;//end of case 2
case 3: deletemember(russian);//if 3 is entered go to deletemember function
break;//end of case 3
case 4:welcomescreen();
break;//end of case 4
case 5:exit (0);//if 5 is entered exit program
break;//endof case 5
default:printf("\t\t\tPlease enter either option 1, 2, 3, 4 or 5\n\n");
system("cls");//clears the screen
mainmenu();//continue program
break;//end of default
}//end of case statement
}//end of option function
//************************************************************************************
void new_member(FILE*russian)
{
newmember gill;
int memnum;
system("color 40");
if((russian=fopen("Database.txt","r+"))==NULL)
printf("File Could not be open\n");
else
system("cls");//clears the screen
printf("\n\n\n\t##############################################################\n\n");
printf("\n\t\tWELCOME TO EGAS DATABASE MANAGEMENT SYSTEM\n\n");
printf("\t##############################################################\n\n");
printf("\t\t\tEnter the Member #: ");
scanf("%d",&memnum);//user inputs
fseek(russian, (memnum - 1) * sizeof (newmember), SEEK_SET);
fread(&gill, sizeof(newmember), 1, russian);
if(gill.mem != 0){//start of if statement to check if member # is not equal to 0
printf(" Member #%d Already contains information.\n",gill.mem);
printf("PRESS ANY KEY TO EXIT!!!\n");
getch();
system("cls");//clears the screen
mainmenu();//continue program
}
else
{
printf("\n\t\t\t Please Enter Last name: ");
scanf("%s",&gill.l_name);//get user input
printf("\n\t\t\t Please Enter First name: ");
scanf("%s",&gill.f_name);//get user input
printf("\n\t\t\t Please Enter Address: ");
scanf("%s",&gill.add_ress);//get user input
printf("\n\t\t\t Please Enter Telephone Number: ");
scanf("%d",&gill.telephone_number);//get user input
printf("\n\t\t\t Spouse Information\n\n");
printf("\n\t\t\t Please Enter Last name: ");
scanf("%s",&gill.lname);//get user input
printf("\n\t\t\t Please Enter First name: ");
scanf("%s",&gill.fname);//get user input
printf("\n\t\t\t Please Enter Address: ");
scanf("%s",&gill.address);//get user input
printf("\n\t\t\t Please Enter Telephone Number: ");
scanf("%d",&gill.telephonenumber);//get user input
printf("\n\t\t\t Please Enter Plan: ");
scanf("%s",&gill.plan);//get user input
printf("\n\t\t\t Please Enter Amount Paid: ");
scanf("%d",&gill.amt_paid);//get user input
printf("\n\t\t\t Please Enter Balance: ");
scanf("%d",&gill.balance);//get user input
gill.mem = memnum;
fseek(russian, (gill.mem -1)* sizeof(newmember),SEEK_SET);
fwrite(&gill, sizeof(newmember), 1, russian);
printf("\n\n\n\t ########################################################\n");
printf("\t THANK YOU FOR USING EGAS DATABASE MANAGEMENT SYSTEM");
printf("\n\t ########################################################\n");
getch();
system("cls");//clears the screen
mainmenu();//continue program
}
}
//******************************************************************************
void existing_member(FILE *russian)
{
int memnum,telephone_number,i,t,l;
int amt_paid;
int balance;
char add_ress[30];
char plan[10];
newmember gill;
if((russian=fopen("Database.txt","r+"))==NULL){
printf("File Could not be open\n");
}else{
system("cls");
printf("Enter Member number : ");
scanf("%d", &memnum);//get user input
fseek(russian,(memnum - 1)* sizeof(newmember),SEEK_SET);
fread(&gill, sizeof(newmember), 1, russian);
if (gill.mem == 0){//start of if statement to check if member # is equal to 0
printf ("Member #%d has no information\n",memnum);
printf("\n\n\n\t ########################################################\n");
printf("\t THANK YOU FOR USING EGAS DATABASE MANAGEMENT SYSTEM");
printf("\n\t ########################################################\n");
getch();
system("cls");
mainmenu();}
else
{
printf("\n%5s%20s%23s%25s","Member#","First Name","Last Name","Telephone#");
printf(" \n\n");
printf("%5d%20s%25s%25d\n\n",gill.mem,gill.f_name,gill.l_name,gill.telephone_number);
printf("\n%5s%20s%23s%25s","Address","Plan","Amount Paid","Balance");
printf(" \n\n");
printf("%5s%20s%25d%25d\n\n",gill.add_ress,gill.plan,gill.amt_paid,gill.balance);
printf("\n\nTo Edit Press 1 or press any key to return to Main Menu: ");
scanf("%d",&t);
if ( t == 1){//start of if statement to check if t is equal to 1
printf("Enter Address: \n");//get user input
scanf("%s",add_ress);//get user input
for (i=0;i<=20;i++)
gill.add_ress[i] = add_ress[i];//replace variable
printf("Enter Telephone #: \n");
scanf("%d",&gill.telephone_number);
gill.telephone_number = telephone_number;//replace variable
printf("Enter Plan: \n");
scanf("%s",gill.plan);
for (l=0;l<=20;l++)
gill.plan[l] = gill.plan[l];
printf("Enter Amount Paid: \n");
scanf("%d",&gill.amt_paid);
gill.amt_paid = gill.amt_paid;
printf("Enter Balance: \n");
scanf("%d",&gill.balance);
gill.balance = gill.balance;
printf("\n%5s%20s%23s%25s","Member#","First Name","Last Name","Telephone#");
printf(" \n\n");
printf("%5d%20s%25s%25d\n\n",gill.mem,gill.f_name,gill.l_name,gill.telephone_number/*,gill.amt_paid,gill.balance*/);
printf("\n%5s%23s%23s%25s","Address","Plan","Amount Paid","Balance");
printf(" \n\n");
printf("%5s%20s%25d%25d\n\n",gill.add_ress,gill.plan,gill.amt_paid,gill.balance);
fseek(russian,(memnum - 1)* sizeof(newmember),SEEK_SET);
fwrite(&gill, sizeof(newmember), 1, russian);
getch();
system("cls");//clears the screen
mainmenu();//continue the program
}else{
printf("\n\n\n\t ##########################################################\n");
printf("\t THANK YOU FOR VIEWING EGAS DATABASE MANAGEMENT SYSTEM");
printf("\n\t ##########################################################\n");
getch();
system("cls");//clears the screen
mainmenu();//continue program
}
}
}
}
//******************************************************************************
void deletemember(FILE *russian)
{
newmember gill,blankgill = {0,"","","",0,"","",0,"","",0,0.0};
int memnum;
int yes;
system("color 4");
if((russian=fopen("Database.txt","r+"))==NULL)
printf("File Could not be open\n");
else
system("cls");//clears the screen
printf("Enter Member Number to delete: ");
scanf("%d",&memnum );//get user input
fseek(russian,(memnum - 1)* sizeof(newmember),SEEK_SET);
fread(&gill, sizeof(newmember), 1, russian);
if (gill.mem == 0)//start of if statement to check if member # is equal to 0
{
printf(" Member # %d does not exist",memnum);
printf("\n\n\n\t ########################################################\n");
printf("\t THANK YOU FOR USING EGAS DATABASE MANAGEMENT SYSTEM");
printf("\n\t ########################################################\n");
getch();
system("cls");//clears the screen
mainmenu();//continue the program
}
else
{
printf("\n%5s%20s%23s%25s","Member#","First Name","Last Name","Telephone#");
printf(" \n\n");
printf("%5d%20s%25s%25d\n\n",gill.mem,gill.f_name,gill.l_name,gill.telephone_number/*,gill.amt_paid,gill.balance*/);
printf("\n%5s%20s%23s%25s","Address","Plan","Amount Paid","Balance");
printf(" \n\n");
printf("%5s%20s%25d%25d\n\n",gill.add_ress,gill.plan,gill.amt_paid,gill.balance);
printf("\n Are you sure ?..\n\n For yes Press 1 :-:\n\n For no press 2 :-:\n");
scanf("%d",&yes);//get user input
if (yes == 1){//start of if statement to check if yes is equal to 1
fseek(russian,(memnum - 1)* sizeof(newmember),SEEK_SET);
fwrite(&blankgill, sizeof(newmember), 1, russian);
system("color 4");
printf("\n\n\t\t Files have been successfully deleted\n\n");
printf("\n\n\n\t ########################################################\n");
printf("\t THANK YOU FOR USING EGAS DATABASE MANAGEMENT SYSTEM");
printf("\n\t ########################################################\n");
getch();
system("cls");//clears the screen
mainmenu();//continue program
}//end of if statement
else
{
printf("\n\n\n\t ########################################################\n");
printf("\t THANK YOU FOR USING EGAS DATABASE MANAGEMENT SYSTEM");
printf("\n\t ########################################################\n");
getch();
system("cls");//clears the screen
mainmenu();//continue program
}//end of else
}
}
J.W.
PRODUCTION
Related Content
How do you use the TABLESAMPLE clause to sample rows from a table?
KarenKg
|
Jul 16, 2024
How do you use the TABLESAMPLE clause to retrieve a random sample of rows?
PaulAnd
|
Jun 23, 2024