0% found this document useful (0 votes)
24 views24 pages

School

The document contains code for a program with multiple functions including a main menu, games involving numbers, words, and general knowledge, as well as animations and interactions to welcome and guide the user.

Uploaded by

Shubh Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views24 pages

School

The document contains code for a program with multiple functions including a main menu, games involving numbers, words, and general knowledge, as well as animations and interactions to welcome and guide the user.

Uploaded by

Shubh Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 24

/* */

/* ----------------- */
/*This is a program to do some interseting tricks with some basics concepts
concept of mathematics and little bit of IQ*/

#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<dos.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>

void thanks() /* function to say ultimate thanks*/


{
clrscr();
int i,size;

char str1[200]={"program coded by MOHAMMAD MINHAJ KHAN (M.M.K)"};


size=strlen(str1);
for(i=0;i<size;i++)
{
textcolor(i);
textbackground(i+5);
cout<<str1[i];
delay(40);
}
gotoxy(35,12);
char str2[200]={"Special thanks to MR. ARSHAD"};
size=strlen(str2);
for(i=0;i<size;i++)
{
cout<<str2[i];
delay(40);
}
delay(450);
return;
}

void virus() /* program to make a virus prank*/


{
clrscr();
int i;
textcolor(BLACK);
textbackground(RED);
for(i=1;i<=100;i++)
{
clrscr();
if(i%5==0)
{
textcolor(WHITE);
gotoxy(35,12);
cout<<" LOADING VIRUS!!!"<<endl<<endl<<endl;
cout<<" "<<i<<"%";
delay(80);
}
else
{
clrscr();
textcolor(BLACK);
gotoxy(35,12);
cout<<endl<<endl<<" "<<i<<"%";

}
delay(150);
clrscr();
for(i=5;i>0;i--)
{
gotoxy(35,12);
cout<<"MK VIRUS LAB....."<<endl<<endl;
cout<<" YOU ARE GOING TO LOOSE YOUR PC IN
"<<i<<" SECONDS!!!!";
delay(1000);
clrscr();
}
delay(100);
cout<<" 1.HARD-DISK CORRUPTION:"<<endl<<endl;
delay(200);
cout<<" completed"<<endl<<endl;
cout<<" 2.MOTHER BOARD CORRUPTION:"<<endl<<endl;
delay(300);
cout<<" completed"<<endl<<endl;
cout<<" 3.INSTALLING CYBERBOB.DLL -->WINDOWS/COMMAND:"<<endl<<endl;
delay(250);
cout<<" completed"<<endl<<endl;
cout<<" PROCRAETORIAN.SYS SUCCESSFULLY PLANTED"<<endl<<endl;
delay(300);
clrscr();
gotoxy(35,12);
cout<<" VIRUS SUCCESFULLY INSTALLED!!!";
textbackground(BLACK);
textcolor(WHITE);
clrscr();
delay(200);
gotoxy(35,12);
cout<<"YOUR PC IS GONE!!!!!!!!"<<endl;
delay(1000);
clrscr();
delay(1000);
textbackground(RED);
gotoxy(35,12);
cout<<"DONT WORRY IT WAS A PRANK"<<endl;
delay(300);
cout<<endl<<" NOW ENJOY THE PROGRAM.....";
delay(1250);
return;
}
/*__________________________________MENU FUNCTION__________________________*/

void menu()
{
clrscr();
textcolor(WHITE);
textbackground(BLUE);
void password();
void testyourbrain(); //function of first game
void wordgame(); //function for second game
/* Displaying of the menu table*/
void gkquiz();
cout<<" ************************************"<<endl;
delay(80);
cout<<" | |"<<endl;
delay(80);
cout<<" | M.K UTILITY PROGRAM |"<<endl;
delay(80);
cout<<" |**********************************|"<<endl;
delay(80);
cout<<" | 1* PLAY WITH NUMBERS |"<<endl;
delay(80);
cout<<" |__________________________________|"<<endl;
delay(80);
cout<<" | 2* PLAY WITH WORDS |"<<endl;
delay(80);
cout<<" |__________________________________|"<<endl;
delay(80);
cout<<" | 3* GK QUIZ |"<<endl;
delay(80);
cout<<" |__________________________________|"<<endl;
delay(80);
cout<<" | 4* BANK MANAGEMENT SYSTEM |"<<endl;
delay(80);
cout<<" |__________________________________|"<<endl;
delay(80);
cout<<" | 5* EXIT |"<<endl;
delay(80);
cout<<" |__________________________________|"<<endl;
int choice;
cout<<" Enter your choice..(1/2/3/4)"<<endl;
do
{

choice=getch(); //variable for taking the choice from the user


}while(choice!='1' && choice!='2' && choice!='3' && choice!='4' && choice!
='5');
//checking the conditions
if(choice=='1')
{
textcolor(BLACK);
textbackground(WHITE);
testyourbrain();
}
else if(choice=='2')
{
textcolor(WHITE);
textbackground(BLUE);
wordgame();
}
else if(choice=='3')
{
gkquiz();
}
else if(choice=='4')
{
password();
}
else
{
thanks();
exit(0);
}
}
/*_______________________________________________________________________
MAIN FUNCTION
_______________________________________________________________________*/
void main()
{
clrscr();

virus();
clrscr();
textcolor(WHITE);
textbackground(RED);
void testyourbrain();
textcolor(WHITE);
textbackground(YELLOW);
void guessinggame();
//displaying of any sentence in animation style
char welcome[]={"WELCOME!!!"};
int i,y,size;
for(i=1;i<72;i++)
{
for(y=1;y<=i;y++)
{
cout<<" ";
}
cputs(welcome);
delay(30);
clrscr();
}
char string1[200]={"Hello welcome to the programmig world of Mohammad Minhaj
Khan, Hope you enjoy "};

size=strlen(string1);
for(i=0;i<size;i++)
{
cout<<string1[i];
delay(30);
}
cout<<endl;
//asking the user to use an additional feature
char string2[200]={"Before entering into my program do you want to check your
brain,if yes (press y) "};
size=strlen(string2);
for(i=0;i<size;i++)
{
cout<<string2[i];
delay(30);
}
cout<<endl;
char choice;
choice=getch();
if(choice=='y' || choice=='Y')
guessinggame();
else
{
clrscr();
cout<<endl;
char string3[200]={"It seems that you dont have trust on your brain,
its sad. Ok leave it....... "};
size=strlen(string3);
for(i=0;i<size;i++)
{
cout<<string3[i];
delay(30);
}
textcolor(WHITE);
textbackground(RED);
menu(); //calling the menu function
}
getch();
}
/*__________________________________HIGH/LOW GAME____________________________*/

void guessinggame()
{
textcolor(BLACK);
textbackground(GREEN);
void testyourbrain();
int totchan=7;
int number; //the computer's random number
int guess; //the user's guess
int chances=0,score=0,chanscor;
char ans;
clrscr();
chances=score=0;
cout<<"Welcome to the High/Low game."<<endl;
cout<<"I(computer) have picked a random number from 0 to 100."<<endl;
cout<<" You must try to guess the number."<<endl;
randomize();
number=(int)(rand()%100);
chanscor=100/totchan; //score for each successful chance
do
{
cout<<"What is your guess? (0 to 100) ";
cin>>guess;
if((guess<0)||(guess>100))
{
cout<<"Sorry, but your guess "<<guess<<"must be from 0 to
100.";
}
else if(guess < number)
{
cout<<guess<<" is low.Try a higher number.";
}
else if(guess > number)
{
cout<<guess<<" is high.Try a lower number.";
}
else //if correct number is guessed
{ //number is correct, and the "do" loop will end below
cout<<guess<<" is correct. Congratulations!";
score=chanscor*(totchan-chances);
cout<<"Your score is "<<score<<endl;
break;
}
chances++;
if(guess!=number)
cout<<"Now you have "<<totchan-chances<<"chances left."<<endl;
if(chances==totchan)
{
cout<<"Only "<<totchan<<"chances are allowed.Better luck
next time"<<endl;
cout<<"The actual number was "<<number<<endl;
break;
}
}while (guess!=number);
cout<<"Thank you for playing High/Low!"<<endl<<endl;
cout<<"Press any key to enter the program";
char a;
cin>>a;
textcolor(WHITE);
textbackground(RED);
menu();
return;
}
/*____________________________________________________________________________
Play with numbers.
____________________________________________________________________________*/

void testyourbrain()
{

textcolor(BLACK);
textbackground(WHITE);
void analyze(char fback[6],int cc1[4][8],int cc2[4][8],int cc3[4][8],int
cc4[4][8],int cc5[4][8],int cc6[4][8]);
//intislising variables.
clrscr(); //pre-defined for clearing the screen

int i,j;
char ans[6];
//intialisation of double-dimansional matrix
int c1[][8]={1 ,3 ,5 ,7 ,9 ,11 ,13 ,15 ,
17,19,21,23,25,27,29,31,
33,35,37,39,41,43,45,47,
49,51,53,55,57,59,61,63 };

int c2[][8]={2,3,6,7,10,11,14,15,
18,19,22,23,26,27,30,31,
34,35,38,39,42,43,46,47,
50,51,54,55,58,59,62,63 };

int c3[][8]={4,5,6,7,12,13,14,15,
20,21,22,23,28,29,30,31,
36,37,38,39,44,45,46,47,
52,53,54,55,60,61,62,63};
int c4[][8]={8,9,10,11,12,13,14,15,
24,25,26,27,28,29,30,31,
40,41,42,43,44,45,46,47,
56,57,58,59,60,61,62,63 };

int c5[][8]={16,17,18,19,20,21,22,23,
24,25,26,27,28,29,30,31,
48,49,50,51,52,53,54,55,
56,57,58,59,60,61,62,63 };

int c6[][8]={32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,
56,57,58,59,60,61,62,63};

char string[200]={"Hello,now you have entered into the new phase of the
program, NOW i m sure that u will get confused "};
int size;
size=strlen(string);
for(i=0;i<size;i++)
{
cout<<string[i];
delay(40);
}
char string2[200]={"Now think of any number between 1 to 63"};
cout<<endl;
size=strlen(string2);
for(i=0;i<size;i++)
{
cout<<string2[i];
delay(40);
}
char string3[200]={"thought??? So lets start the game..........."};
cout<<endl;
size=strlen(string3);
for(i=0;i<size;i++)
{
cout<<string3[i];
delay(40);
}
cout<<endl;
delay(300);
char string4[200]={"Is that number present here(y/n)"};
cout<<endl;
do
{ clrscr();
size=strlen(string4);
for(i=0;i<size;i++)
{
cout<<string4[i];
delay(40);
}
cout<<endl;
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
if(i==0 && j<5)
cout<<c1[i][j]<<" "<<"?"<<" ";
else
cout<<c1[i][j]<<" "<<"?"<<" ";
}
cout<<endl<<endl;
}
ans[0]=getch();
}while(ans[0]!='y' && ans[0]!='Y' && ans[0]!='n' && ans[0]!='N');

char string5[200]={"Is that number present here(y/n)"};


cout<<endl;
do
{
clrscr();
size=strlen(string5);
for(i=0;i<size;i++)
{
cout<<string5[i];
delay(40);
}
cout<<endl;
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
if(i==0 && j<4)
cout<<c2[i][j]<<" "<<"?"<<" ";
else
cout<<c2[i][j]<<" "<<"?"<<" ";
}
cout<<endl<<endl;
}
ans[1]=getch();
}while(ans[1]!='y' && ans[1]!='Y' && ans[1]!='n' && ans[1]!='N');

char string6[200]={"Is that number present here(y/n)"};


do
{
clrscr();
cout<<endl;
size=strlen(string6);
for(i=0;i<size;i++)
{
cout<<string6[i];
delay(40);
}
cout<<endl;
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
if(i==0 && j<4)
cout<<c3[i][j]<<" "<<"?"<<" ";
else
cout<<c3[i][j]<<" "<<"?"<<" ";
}
cout<<endl<<endl;
}
ans[2]=getch();
}while(ans[2]!='y' && ans[2]!='Y' && ans[2]!='n' && ans[2]!='N');
char string7[200]={"Is that number present here(y/n)"};
do
{ clrscr();
cout<<endl;
size=strlen(string7);
for(i=0;i<size;i++)
{
cout<<string7[i];
delay(40);
}
cout<<endl;
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
if(i==0 && j<2)
cout<<c4[i][j]<<" "<<"?"<<" ";
else
cout<<c4[i][j]<<" "<<"?"<<" ";
}
cout<<endl<<endl;
}
ans[3]=getch();
}while(ans[3]!='y' && ans[3]!='Y' && ans[3]!='n' && ans[3]!='N');

char string8[200]={"Is that number present here(y/n)"};


do
{ clrscr();
cout<<endl;
size=strlen(string8);
for(i=0;i<size;i++)
{
cout<<string4[i];
delay(60);
}
cout<<endl;
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
if(i==0 && j<0)
cout<<c5[i][j]<<" "<<"?"<<" ";
else
cout<<c5[i][j]<<" "<<"?"<<" ";
}
cout<<endl<<endl;
}
ans[4]=getch();
}while(ans[4]!='y' && ans[4]!='Y' && ans[4]!='n' && ans[4]!='N');

char string9[200]={"Is that number present here(y/n)"};


do
{ clrscr();
cout<<endl;
size=strlen(string9);
for(i=0;i<size;i++)
{
cout<<string9[i];
delay(40);
}
cout<<endl;
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
if(i==0 && j<0)
cout<<c6[i][j]<<" "<<"?"<<" ";
else
cout<<c6[i][j]<<" "<<"?"<<" ";
}
cout<<endl<<endl;
}
ans[5]=getch();
}while(ans[5]!='y' && ans[5]!='Y' && ans[5]!='n' && ans[5]!='N');

analyze(ans,c1,c2,c3,c4,c5,c6); //function for calculating the value


return;
}

void analyze(char fback[6],int cc1[4][8],int cc2[4][8],int cc3[4][8],int cc4[4]


[8],int cc5[4][8],int cc6[4][8])
{
clrscr();
char s1[100]={"Analyzing.............................................."};
int i,j,k,correct[6];
int size;
size=strlen(s1);
for(i=0;i<size;i++)
{
cout<<s1[i];
delay(50);
}
for(i=0;i<6;i++)
{
if(fback[i]=='y' || fback[i]=='Y')
correct[i]=0;
else if(fback[i]=='n' || fback[i]=='N')
correct[i]=1;
}
int checkall[63][6];
for(i=0;i<63;i++)
{
for(j=0;j<6;j++)
checkall[i][j]=1;
}
for(i=1;i<=63;i++)
{
for(j=0;j<4;j++)
{
for(k=0;k<8;k++)
{
if(cc1[j][k]==i)
{
checkall[i-1][0]=0;
}

if(cc2[j][k]==i)
{
checkall[i-1][1]=0;
}

if(cc3[j][k]==i)
{
checkall[i-1][2]=0;
}

if(cc4[j][k]==i)
{
checkall[i-1][3]=0;
}

if(cc5[j][k]==i)
{
checkall[i-1][4]=0;
}

if(cc6[j][k]==i)
{
checkall[i-1][5]=0;
}
}
}
}
int count=0;
for(i=0;i<63;i++)
{
for(j=0,k=0;j<6,k<6;j++,k++)
{
if(correct[j]==checkall[i][k])
count++;
if(count==6)
{
cout<<endl<<"Isn't it is supprising!!!"<<endl<<"Your number
was "<<i+1;
}
}
count=0;
}
cout<<endl<<endl;
cout<<"Press 1 to go back to main menu ";
int back;
cin>>back;
if(back==1)
{
textcolor(WHITE);
textbackground(RED);
menu();
}
else
{
thanks();
exit(0);
}
return;
}
/*____________________________________________________________________________
Play with words.
____________________________________________________________________________*/

void wordgame()
{
clrscr();
int i,j,size,serial[5]={1,2,3,4,5};
char string1[]={"Think of any word.... thought???? (for easyness take a
small word....)"};
size=strlen(string1);
for(i=0;i<size;i++)
{
cout<<string1[i];
delay(50);
if(i==22)
{
delay(100);
cout<<endl;
}
}
cout<<endl<<endl;
char table1[]
[5]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T
','U','V','W','X','Y','Z',' ',' ',' ',' '};
char string2[]={"Enter the number of letters in your word:- "}; //taking the
required information from the user
size=strlen(string2);
for(i=0;i<size;i++)
{
cout<<string2[i];
delay(50);
}
int z,num,pos1[20],pos2[20];
cin>>num;
clrscr();
for(z=0;z<num;z++)
{
clrscr();
cout<<endl<<" Table 1"<<endl<<endl;
for(i=0;i<5;i++)
cout<<serial[i]<<" ";
cout<<endl<<endl;
delay(80);
for(i=0;i<6;i++)
{
for(j=0;j<5;j++)
{
cout<<table1[i][j]<<" ";
}
cout<<endl;
delay(80);
}
cout<<endl<<endl;
cout<<"Enter the coloumn of letter "<<z+1<<":- ";
cin>>pos1[z];
}
char table2[20][6];
for(i=0;i<num;i++)
{
for(j=0;j<6;j++)
{
table2[i][j]=table1[j][pos1[i]-1];
}
}

for(z=0;z<num;z++)
{
clrscr();
cout<<endl<<" Table 2"<<endl<<endl;
for(i=0;i<5;i++)
cout<<serial[i]<<" ";
cout<<6;
cout<<endl<<endl;
for(i=0;i<num;i++)
{
for(j=0;j<6;j++)
{
cout<<table2[i][j]<<" ";
}
cout<<endl;
delay(80);
}
cout<<endl;
cout<<"Enter the column of letter "<<z+1<<":- ";
cin>>pos2[z];
}
char string3[]={"Analyzing result....................................... "};
size=strlen(string3);
for(i=0;i<size;i++)
{
cout<<string3[i];
delay(50);
}
cout<<endl<<endl<<"Isn't it is interesting??"<<endl<<"Your word was:- ";
delay(300);
for(z=0;z<num;z++)
{
for(i=0;i<6;i++)
{
for(j=0;j<num;j++)
{
if(table1[i][pos1[z]-1]==table2[j][pos2[z]-1])
{

cout<<table1[i][pos1[z]-1];
break;
}
}
}
}
cout<<endl<<endl<<endl<<endl<<"Press 1 to go back to main menu... else press
any other key to exit";
int ex;
cin>>ex;
if(ex==1)
{
textcolor(WHITE);
textbackground(RED);
menu();
}
else
{
thanks();
exit(0);
}
return;
}
/*____________________________________________________________________________
GK QUIZ
______________________________________________________________________________*/
void gkquiz()
{
clrscr();
textcolor(BLACK);
textbackground(YELLOW);
int x,y,z;
x=y=z=0;
char ch1[100],ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9,ch10,ch11;
clrscr();
cout<<" Welcome "<<endl;
cout<<" Enter answer in form of 'a','b' and'c'only."<<endl;

cout<<endl<<endl<<"What is called as ' THE HOLY LAND'?"<<endl<<"


a.Jerusalem"<<endl<<" b.Mathura"<<endl<<" c.Mecca"<<endl;
ch2=getch();
if(ch2=='a')
{
x=x+10;
cout<<"Good Job. Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
cout<<" What is called as ' THE ROOF OF
THEWORLD'?"<<endl<<"a.Nepal"<<endl<<"b.Rome"<<endl<<"c.Tibet"<<endl;
ch2=getch();
if(ch2=='c')
{
x=x+10;
cout<<"Good Job.Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();

cout<<" What is called as ' THE LAND OF RISING


SUN'?"<<endl<<"a.Chicago"<<endl<<"b.Japan"<<endl<<"c.Tibet"<<endl;
ch2=getch();
if(ch2=='b')
{
x=x+10;
cout<<"Good Job. Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
cout<<"What is called as ' THE GIFT OF
NILE'?"<<endl<<"a.Chicago"<<endl<<"b.Egypt"<<endl<<"c.Africa"<<endl;
ch2=getch();
if(ch2=='b')
{
x=x+10;
cout<<"Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
cout<<"What is called as ' THE LAND OF MIDNIGHT SUN'?"<<endl<<"
a.Norway"<<endl<<" b.Japan"<<endl<<" c.Australia"<<endl;
ch2=getch();
if(ch2=='a')
{
x=x+10;
cout<<"Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
cout<<" What is called as ' THE LAND OFTHUNDERBOLT'?"<<endl<<" a.Bhutan
"<<endl<<"b.Canada"<<endl<<" c.Arab"<<endl;
ch2=getch();
if(ch2=='a')
{
x=x+10;
cout<<" Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
cout<<" What is called as ' THE WINDY CITY?"<<endl<<" a.Jerusalem"<<endl<<"
b.Japan"<<endl<<" c.Chicago"<<endl;
ch2=getch();
if(ch2=='c')
{
x=x+10;
cout<<" Your score is "<<x;
}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
cout<<" What is called as ' THE LAND OF WHITE ELEPHANTS'?"<<endl<<"
a.Bangladesh "<<endl<<"b.Thailand "<<endl<<"c.India"<<endl;
ch2=getch();
if(ch2=='b')
{
x=x+10;
cout<<" Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
cout<<" What is called as ' THE CITY OF SEVEN HILLS'?"<<endl<<"
a.Rome"<<endl<<" b.Nilgiri Hills"<<endl<<" c.Tibet"<<endl;
ch2=getch();
if(ch2=='a')
{
x=x+10;
cout<<"Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
cout<<" What is called as ' THE DARK CONTIENENT'?"<<endl<<" a.Asia"<<endl<<"
b.Australia"<<endl<<" c.Africa"<<endl;
ch2=getch();
if(ch2=='c')
{
x=x+10;
cout<<" Your score is "<<x;

}
else
cout<<"Sorry wrong answer.";
getch();
clrscr();
if(x==100)
cout<<"No cheating...... You have done this earlier also.";
if(x==90)
cout<<"You are extremely intelligent Your Score is 90";
if(x==80)
cout<<"You are intelligent Your Score is 80";
if(50==x||x==70||x==60)
cout<<"You are average Your Score is "<<x<<" Better luck next time";
else if(x<=40)
cout<<"No use........ Not even 5 questions right";
cout<<endl<<endl<<"PRESS 1 to go back to main menu or press any other key to
exit";
int b;
cin>>b;
if(b==1)
{
textcolor(WHITE);
textbackground(RED);
menu();
}
else
{
thanks();
exit(0);
}
getch();
}
/*-----------------------------------PASSWORD FNCTION------------------------*/
void password()
{
clrscr();
textbackground(BLUE);
void bank();
int str[20],pw[]={112,109,109,111,100,105},s,x,a,p=0,count=0;
char b;
do
{
cout<<"ENTER THE PASSWORD ";
for(int i=0;i<20;i++)
{
b=getch();
x=b;
str[i]=x;
cout<<"*";
if(str[i]==13)
break;
}
clrscr();
a=i;
for(i=0;i<a;i++)
{
if(str[i]!=pw[i])
{
p=1;
break;
}
}
if(p==0)
{
bank();
break;
}
else
{
count++;
cout<<"wrong password"<<endl<<"ENTER THE PASSWORD AGAIN"<<endl;
}
p=0;
}while(count!=3);
menu();
}
//***************************************************************
// CLASS USED IN PROJECT
//****************************************************************
int xx=0;
class account
{
int acno, deposit, withdraw;
char name[50];
char type;
public:
void create_account()
{
cout<<"\n\n====NEW ACCOUNT ENTRY FORM====\n\n";
delay(100);
cout<<"\nEnter The account Number : ";
cin>>acno;
cout<<"\nEnter The Name of The account Holder : ";
gets(name);
cout<<"\nEnter Type of The account (C/S) : ";
cin>>type;
type=toupper(type);
cout<<"\nEnter Initial amount >=500 for Saving >=1000 for current :";
cin>>deposit;
cout<<"\n\n\nYour Account Created Successfully ..";
}
void show_account()
{
cout<<"\n\n-ACCOUNT STATUS-\n";
cout<<"\nAccount No. : "<<acno;
cout<<"\nAccount Holder Name :"<<name;
cout<<"\nType of Account : "<<type;
cout<<"\nBalance amount : "<<deposit;
}
void modify_account()
{
cout<<"\nAccount No. : "<<acno;
cout<<"\nModify Account Holder Name : ";
gets(name);
cout<<"Modify Type of Account : ";cin>>type;
cout<<"Modify Balance amount : ";
cin>>deposit;
}
void dep(int x)
{
deposit+=x;
}
void draw(int x)
{
deposit-=x;
}
void report()
{
gotoxy(5,7+xx);
cout<<acno;
gotoxy(20,7+xx);
cout<<name;
gotoxy(45,7+xx);
cout<<type;
gotoxy(60,7+xx);
cout<<deposit<<endl;
xx++;
}
int retacno()
{

return acno;
}
float retdeposit()
{
return deposit;
}
char rettype()
{
return type;
}
}; //class ends here

//***************************************************************
// global declaration for stream object, object
//****************************************************************

fstream fp;
account ac;

//***************************************************************
// function to write in file
//****************************************************************

void write_account()
{
textcolor(WHITE);
textbackground(GREEN);
fp.open("account.dat",ios::out|ios::app);
ac.create_account();
fp.write((char*)&ac,sizeof(account));
fp.close();
}

//***************************************************************
// function to read specific record from file
//****************************************************************

void display_sp()
{
textcolor(WHITE);
textbackground(RED);
int n;
cout<<"\n\n====BALANCE DETAILS===="<<endl<<endl;
cout<<"\n\nEnter the Account Number : ";
cin>>n;
int flag=0;
fp.open("account.dat",ios::in);
while(fp.read((char*)&ac,sizeof(account)))
{
if(ac.retacno()==n)
{
ac.show_account();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<" Account Number does not exist";
getch();
}

//***************************************************************
// function to modify record of file
//****************************************************************

void modify_account()
{
textcolor(BLACK);
textbackground(WHITE);
int no,found=0;
cout<<"\n\n====MODIFY RECORD===="<<endl<<endl;
cout<<"\n\nEnter the Account No. : ";
cin>>no;
fp.open("account.dat",ios::in|ios::out);
while(fp.read((char*)&ac,sizeof(account)) && found==0)
{
if(ac.retacno()==no)
{
ac.show_account();
cout<<"\n\n\n"<<"Enter the New Details-"<<"\n";
ac.modify_account();
int pos=-1*sizeof(ac);
fp.seekp(pos,ios::cur);
fp.write((char*)&ac,sizeof(account));
cout<<"\n\n\t Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found ";
getch();
}

//***************************************************************
// function to delete record of file
//****************************************************************

void delete_account()
{
textcolor(RED);
textbackground(YELLOW);
int no;
cout<<"\n\n====Delete Record===="<<endl<<endl;
cout<<"\n\nEnter The Account No. : ";
cin>>no;
fp.open("account.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&ac,sizeof(account)))
{
if(ac.retacno()!=no)
{
fp2.write((char*)&ac,sizeof(account));
}
}
fp2.close();
fp.close();
remove("account.dat");
rename("Temp.dat","account.dat");
cout<<"\n\n\tRecord Deleted ..";
getch();
}

//***************************************************************
// function to display all accounts deposit list
//****************************************************************

void display_all()
{
textcolor(BLACK);
textbackground(7);
fp.open("account.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN ";
getch();
return;
}
cout<<"\n\n\t\t\t ACCOUNT HOLDER LIST\n\n";

cout<<"===================================================================\n";
cout<<"A/c no.\tNAME\t\t\tType\t\t\tBalance\n";

cout<<"===================================================================\n";

while(fp.read((char*)&ac,sizeof(account)))
{
ac.report();
}
xx=0;
fp.close();
getch();
}

//***************************************************************
// function to deposit and withdraw amounts
//****************************************************************

void deposit_withdraw(int option)


{
textcolor(BLUE);
textbackground(4);
int no,found=0,amt;
cout<<"\n\n====ACCOUNT TRANSCATION FORM===="<<endl<<endl;
cout<<" Enter The account No. : ";
cin>>no;
fp.open("account.dat",ios::in|ios::out);
while(fp.read((char*)&ac,sizeof(account)) && found==0)
{
if(ac.retacno()==no)
{
ac.show_account();
if(option==1)
{
cout<<"\n\nEnter The amount to DEPOSIT :";
cin>>amt;
ac.dep(amt);
}
if(option==2)
{
cout<<"\n\nEnter The amount to WITHDRAW : ";
cin>>amt;
int bal=ac.retdeposit()-amt;
if((bal<500 && ac.rettype()=='S') || (bal<1000 &&
ac.rettype()=='C'))
cout<<"\nInsufficience balance";
else
ac.draw(amt);
}
int pos=-1*sizeof(ac);
fp.seekp(pos,ios::cur);
fp.write((char*)&ac,sizeof(account));
cout<<"\n\n\t Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found ";
getch();
}

//***************************************************************
// INTRODUCTION FUNCTION
//****************************************************************

void intro()
{
clrscr();
textcolor(RED);
textbackground(WHITE);
gotoxy(20,5);
for(int i=0;i<40;i++)
{
cout<<"*";
delay(40);
}
char str[]={"BANK MANAGEMENT SYSTEM"};

gotoxy(28,8);
for(i=0;i<strlen(str);i++)
{
cout<<str[i];
delay(50);
}
gotoxy(20,11);
for(i=0;i<40;i++)
{
cout<<"*";
delay(40);
}
char str2[]={"Made by:- Mohammad Minhaj Khan"};
char str3[]={"School:- Rajputana Public School"};
gotoxy(15,15);
for(i=0;i<strlen(str2);i++)
{
cout<<str2[i];
delay(50);
}
gotoxy(15,17);
for(i=0;i<strlen(str3);i++)
{
cout<<str3[i];
delay(50);
}

getch();
}

//***************************************************************
// THE MAIN FUNCTION OF PROGRAM
//****************************************************************

void bank()
{

char ch;
intro();
textcolor(WHITE);
textbackground(BLUE);
do
{
clrscr();
cout<<"\n\n\n\tMAIN MENU";
delay(40);
cout<<"\n\n\t01. NEW ACCOUNT";
delay(40);
cout<<"\n\n\t02. DEPOSIT AMOUNT";
delay(40);
cout<<"\n\n\t03. WITHDRAW AMOUNT";
delay(40);
cout<<"\n\n\t04. BALANCE ENQUIRY";
delay(40);
cout<<"\n\n\t05. ALL ACCOUNT HOLDER LIST";
delay(40);
cout<<"\n\n\t06. CLOSE AN ACCOUNT";
delay(40);
cout<<"\n\n\t07. MODIFY AN ACCOUNT";
delay(40);
cout<<"\n\n\t08. EXIT";
delay(40);
cout<<"\n\n\tSelect Your Option (1-8) ";
ch=getche();
clrscr();
switch(ch)
{
case '1' : write_account();
getch();
break;
case '2': deposit_withdraw(1);
break;
case '3': deposit_withdraw(2);
break;
case '4': display_sp();
break;
case '5': display_all();
break;
case '6': delete_account();
break;
case '7': modify_account();
break;
case '8': menu();
default : cout<<"\a";
}
}while(ch!='8');
}

//***************************************************************
// END OF PROJECT
//*************
/* _________________________________________________________________________
| |
| PROGRAM ENDS!!! |
|________________________________________________________________________|*/

You might also like