Thursday, September 18, 2008

Chinthakayala Ravi Trailors:

http://rapidshare.com/files/146284999/Chintakayala_Ravi_2008_Trailer_1_YM.avi

http://rapidshare.com/files/146285000/Chintakayala_Ravi_Trailer_2.avi

Chintakayala Ravi Audio(Mp3) High Quality:

http://rapidshare.com/files/146280587/ChintakayalaRavi.5.Enduko.mp3

http://rapidshare.com/files/146280586/ChintakayalaRavi.4.Merupula.mp3

http://rapidshare.com/files/146280584/ChintakayalaRavi.2.OhSunita.mp3

http://rapidshare.com/files/146280585/ChintakayalaRavi.3.ShavaShava.mp3

http://rapidshare.com/files/146280583/ChintakayalaRavi.1.Bagundey.mp3

Saturday, September 13, 2008

Astachemma Songs Download:

http://rapidshare.com/files/144870331/Ashta_Chamma_-_Grafix_-_01.Nammalo_Ledo.mp3

http://rapidshare.com/files/144870332/Ashta_Chamma_-_Grafix_-_02.Hello_Antoo.mp3

http://rapidshare.com/files/144870333/Ashta_Chamma_-_Grafix_-_03.Aadinchi_Ashta_Chamma.mp3

http://rapidshare.com/files/144870335/Ashta_Chamma_-_Grafix_-_05.Ashta_Chamma_Theme.mp3

http://rapidshare.com/files/144870334/Ashta_Chamma_-_Grafix_-_04.Tidathara_Kodathara.mp3

Sunday, September 7, 2008

Subramaniapuram Swathi Interview:

Subramaniapuram Colors Swathi Interview:


Tell us a little bit about yourself

I have completed graduation in Biotechnology and have always been a studious girl. My dad was in Indian navy and so I did schooling in different places and finally we are now settled in Hyderabad. I was doing my graduation when director Krishna Vamsi offered me this off-beat film in Telugu Danger and later I did Aadavari Matalaku Ardhalu Verule .

Actually Subramaniapuram is the first movie where I play heroine in a pucca commercial film.

Are you elated after knowing that Subramaniapuram is turning out to be a hit?
I can’t tell you how happy I am. I came into the industry without any formal training in acting, no Godfathers, no industry connections and had never made a portfolio or done make-up or screen tests. When we started work for the film, there were lots of initial hiccups like continuous rain etc. But the entire unit was so kicked-up and optimistic that we completed the film on time.

Do you identify with the Thulasi character that you played in Subramaniapuram?
Not at all. I am the opposite of Thulasi in real life - fun loving, outgoing and is thoroughly a city-bred girl. It was very difficult for me to have that Vekkam (shy and coy) look on my face and body language. Initially when I got this offer to do the role, I was very skeptical if I could do justice. First and foremost- I did not know Tamil and to shoot continuously in a village with new people around was a challenge. But when we started shoot my thoughts completely changed.

Why do you say so?
The unit of Subramaniapuram was like a family. Everybody was hard working, was passionate about their work and above we all had great faith in the script. It was a great team spirit and everyone was so involved as they wanted to prove themselves, including my director Sasikumar. So now when I hear that the film is a hit, I feel so happy that all the hard work that we all put into the film has been handsomely rewarded and I have to say that Tamil audiences have proved that a good film will always be appreciated, in spite of not having any big stars or technicians.

Any interesting incidents on the sets?
The climax scene was a very touchy one. Both I and Jai did not use glycerin and even after the shot was Okayed by the director, I was crying and it took me quiet sometime to be normal. I can never forget that.

Do you think that violence was a bit too much in the film?
I have to share this with you. I had asked Sasikumar the same thing while we were shooting. And the next day, he showed me a news item in a local daily about an incident that happened in Madurai the previous day which was similar to our story. So he tried to tell me that his story was not a fantasy and such incidents and characters are a part of normal life in Madurai area.

Do you plan to continue as actress?
I, did not plan anything in life. It happened an anchor on TV or entering films. Everything just happened for me including Subramaniapuram turning out to be a big hit. I am currently doing a Telugu film titled Ashta Chamma with a new hero with a National Award winning director. I want to do good films and if it does not work out I have my education to fall back on (smiles).

What do you do when you are not shooting?
I watch movies, listen to music and basically I am a very homely girl

Exclusive Interview with Colours Swathi:

Exclusive Interview with Colours Swathi:

Colors' Swathi needs no introduction. She entertains the small TV audience with her show Colors. Now she had done the role of Mahalaxmi in Krishnavamsi's Danger and made her debut into the big screen. Though many producers were trying to cast her as heroine in their production, she made it on to the big screen only now. Here are the views of Swathi expressed in an exclusive interview.

Tell us a little bit about yourself
My childhood is like a fairy tale. I am very lucky in that regard. I am treated as a princess at home. It is always fun time at home. My father is a navy man. One day I was visiting my aunty when I took the audition. I got selected and stepped in to anchoring. Since most part of my childhood and education was in Mumbai, I learnt Telugu after I got into anchoring with MAA. I prefer good command on the language in which you present. Not a mixture of various languages and make it funky.

How did you get into Danger?
One day I got a call from Krishnavamsi. I thought it was for audio release or to dub for some Hindi artist. But he was offereing me the role of Mahalaxmi. I was a fan of Krishnavamsi's direction from the beginning. So I could not resist.

Do you plan on continuing as actress?
I did not plan on becoming an anchor. Similarly, I did not plan or try to become an actress. It happened. So I am not going to plan (laughs). But I would do any thing with sincerity and dedication.

You are expecting all characters to be like Mahalaxmi's?
No, I am not saying that. What I mean to say is that it depends on the story.

Are you not restricting yourself with chances then?
I agree there is lot of money with playing heroine. However, if I don't handle it with discretion, it will ruin my freedom. I don't need money and status that would take away simple feel of freedom from me. I did the role of Mahalaxmi. But still I could go on road; go for shopping with my mom etc. If I continue doing regular heroine characters, I will not be able to do that any more. I give peace and freedom more priority than money and related.

What is your strength and weakness?
My plus and minus are my words. In my childhood, I was chided for being talkative. Now that turned to my advantage.

Do you see any resemblance in you with Mahalakshmi character?
In fact, yes. I am a very good girl, you know (laugsh).

What is your thought about Krishnavamsi as director.
He is undoubtedly one of the best directors.

Did you read the story of Danger before signing up for it?
Yes. In fact, Krishnavamsi always teases me by saying I did not sign up until I read the script.

What scenes did you like the best in Danger?
When Karthik confesses to Raj Nayak; The scene where the friends get washed away in sand; Personally, I liked the scene when Satya suddenly comes to me in the forest.

What is the best compliment you got for this film?
It came from none other than my director Krishnavamsi. He complimented me that I am a born artist.

How did you feel when you saw the first copy?
When I saw the film for the first time, I did not even realize it was over. I had to go second time to see myself. The first time, I was only seeing Mahalaxmi. It was a thrilling experience.

Before the interview concluded, I asked Swathi about her liking for music and dance. She loves both and she said she even performed few dances programs during school time.

SendMail

/** SendMail.java
** Presents a form to the user, and sends the information entered, in addition
* to "hidden" information in the form, to a predefined recipient via e-mail.
* Can be run either as a browser remote applet, or standalone.
** HTML parameters:
** RECIPIENT the e-mail address of the recipient (if not run from a browser,
* the recipient must be hardcoded in the main routine).
**/
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.applet.*;
import java.io.*;
import java.util.Date;
/*** The applet.*/
public class SendMail extends Applet
{// The e-mail address all messages are to be sent to; specified in HTML
String webmasterEmail = null;
String serverHostName = null;
boolean standalone = false;
int smtpPort = 25;
Socket socket;
PrintStream ps;
DataInputStream dis;
InetAddress rina;
InetAddress lina;
Form form;
/*** Initialize the applet.*/
public void init()
{
setBackground(Color.white);
form = new Form(this);
add(form);
resize(600, 450);
if (serverHostName == null)
serverHostName = getCodeBase().getHost();
if (webmasterEmail == null) webmasterEmail = getParameter("RECIPIENT");
}
/*** Show status to the user.*/
public void showStatus(String s)
{
System.out.println(s);
if (standalone)
return;
super.showStatus(s);
}
/*** Send an e-mail message.*/
public void send()
throws IOException, Exception
{
// Open connection to SMTP server
socket = new Socket(serverHostName, smtpPort);
// Send the form contents as a message
try
{
rina = socket.getInetAddress();
lina = rina.getLocalHost();
ps = new PrintStream(socket.getOutputStream());
dis = new DataInputStream(socket.getInputStream());
// Send message
sendline("HELO " + lina.toString());
sendline("MAIL FROM:" + form.email());
sendline("RCPT TO:" + webmasterEmail);
sendline("DATA");
sendline(form.message());
sendline(".");
}
catch (Exception ex)
{
socket.close();
throw ex;
}
// Close connection
socket.close();
}
/*** Send a line of data to the server, and retrieve the handshake*/
void sendline(String data)
throws IOException
{
System.out.println("sendline out:" + data);
ps.println(data);
ps.flush();
String s = dis.readLine();
System.out.println("sendline in:" + s);
}
/*** Main routine, for standalone program execution */
public static void ain(String args[])
{
SendMail ap = new SendMail();
ap.serverHostName = "www.your_organization.com";
ap.webmasterEmail = "recipient@your_organization.com";
ap.standalone = true;
ClosableFrame fr = new ClosableFrame("SendMail");
ap.init();
fr.add("Center", ap);
fr.resize(600, 450);
fr.show();
ap.start();
}
}
/*** A form for obtaining user input. Customize this for your application, just
* as you would customize an HTML form for a Web-based e-mail application. */
class Form extends Panel
{
SendMail applet; // The form's elements...
Label nameLabel;
TextField nameField;
Label emailLabel;
TextField emailField;
Label orgLabel;
TextField orgField;
Label msgBodyLabel;
TextArea msgBodyArea;
Button sendButton;
/*** The constructor */
public Form(SendMail ap)
{
applet = ap;
setBackground(Color.white);
setLayout(new GridLayout(2, 1));
// Create a panel to put the text fields and button on
Panel p = new Panel();
p.setLayout(new GridLayout(8, 1));
// Instantiate all the elements, and add them to their containers...
p.add(sendButton = new Button("Send"));
p.add(nameLabel = new Label("Your Name:"));
p.add(nameField = new TextField(60));
p.add(emailLabel = new Label("Your E-mail address:"));
p.add(emailField = new TextField(60));
p.add(orgLabel = new Label("Your Organization:"));
p.add(orgField = new TextField(60));
p.add(msgBodyLabel = new Label("Your Message:"));
add(p);
add(msgBodyArea = new TextArea(3, 60));
// Set the size of the form
resize(550, 400);
}
/*** Return the value in the e-mail address field in the form */
public String email()
{
return emailField.getText();
}
/*** Return the contents of the body of the form, including any "hidden" fields.*/
public String message()
{
String m = "";
m += nameLabel.getText();
m += nameField.getText();
m += "\n";
m += orgLabel.getText();
m += orgField.getText();
m += "\n";
m += "Web Origin:";
if (!applet.standalone) m += applet.getDocumentBase();
m += "\n";
m += "Date Sent:";
m += (new Date()).toString();
m += "\n";
m += msgBodyLabel.getText();
m += msgBodyArea.getText();
m += "\n";
return m;
}
/*** Respond to the button click event: send the message. */
public boolean handleEvent(Event e)
{
if ((e.target == sendButton) && (e.id == Event.ACTION_EVENT))
{
// User clicked the Send button; send the message
try { applet.send(); }
catch (Exception ex)
{
applet.showStatus("Error; message send failed:\n " + ex.toString());
return true;
}
applet.showStatus("Message sent");
return true;
}
// Not an event to handle; let the super class try
return super.handleEvent(e);
}
}
/*** Create a frame that can be closed; only used if run standalone. */
class ClosableFrame extends Frame
{
public ClosableFrame(String t)
{
super(t);
}
public boolean handleEvent(Event e)
{
if (e.id == Event.WINDOW_DESTROY) System.exit(0);
return super.handleEvent(e);
}
}

Banking Project

//banking Project


#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

void gra1();
void gra2();
//Program segment to display some graphic
void box(int,int);

//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO DRAW BOX
ETC.

//**********************************************************
class shape
{
public :
//Public member functions
void line_hor(int, int, int, char) ;
void line_ver(int, int, int, char) ;
void box(int,int,int,int,char) ;
} ;


//**********************************************************
// THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU

//**********************************************************
class control
{
public :
void main_menu(void) ;
//Public member functions
void help(void) ;
private :
void edit_menu(void) ; //Private
member functions
} ;

//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO INITIAL DEPOSIT
//**********************************************************
class initial
{
public :
void add_to_file(int, char t_name[30],
char t_address[60], float) ;
void display_list(void) ;
void delete_account(int) ;
void update_balance(int, float) ;
void modify(void) ;
int last_accno(void) ;
int found_account(int) ;
char *return_name(int) ;
//So that the private members of class
char *return_address(int) ;
//can be used in required segments.
float give_balance(int) ;
int recordno(int) ;
void display(int) ;
private :
void modify_account(int, char
t_name[30], char t_address[60]) ;
void box_for_list(void) ;
int accno ;
//Private member elements
char name[30], address[60] ;
float balance ;
} ;

//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO TRANSACTIONS
//**********************************************************
class account
{
public :
void new_account(void) ;
void close_account(void) ;
void display_account(void) ;
void transaction(void) ;
void clear(int,int) ;
private :
void add_to_file(int, int, int, int,
char, char
t_type[10], float, float, float) ;
void delete_account(int) ;
int no_of_days(int, int, int, int,
int,
int) ;
float calculate_interest(int, float) ;
void display(int) ;
void box_for_display(int) ;
int accno ;
char type[10] ;
//
Cheque or Cash
int dd, mm, yy ;
//
Date
char tran ;
// Deposit or Withdraw
float interest,
amount,
balance ;
} ;

//**********************************************************
// CLASS SHAPE :: FUNCTION TO DRAW HORIZONTAL LINE
//**********************************************************
void shape :: line_hor(int column1, int column2, int row, char c)
{
for ( column1; column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cout < }
}

//**********************************************************
// CLASS SHAPE :: FUNCTION TO DRAW VERTICAL LINE
//**********************************************************
void shape :: line_ver(int row1, int row2, int column, char c)
{
for ( row1; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
cout < }
}

//**********************************************************
// CLASS SHAPE :: FUNCTION TO DRAW BOX LINE
//**********************************************************
void shape :: box(int column1, int row1, int column2, int row2, char
c)
{
char ch=218 ;
char c1, c2, c3, c4 ;
char l1=196, l2=179 ;
if (c == ch)
{
c1=218 ;
c2=191 ;
c3=192 ;
c4=217 ;
l1 = 196 ;
l2 = 179 ;
}
else
{
c1=c ;
c2=c ;
c3=c ;
c4=c ;
l1 = c ;
l2 = c ;
}
gotoxy(column1,row1) ;
cout < gotoxy(column2,row1) ;
cout < gotoxy(column1,row2) ;
cout < gotoxy(column2,row2) ;
cout < column1++ ;
column2-- ;
line_hor(column1,column2,row1,l1) ;
line_hor(column1,column2,row2,l1) ;
column1-- ;
column2++ ;
row1++ ;
row2-- ;
line_ver(row1,row2,column1,l2) ;
line_ver(row1,row2,column2,l2) ;
}

//************************************************************************
*
// CLASS CONTROL :: FUNCTION TO DISPLAY MAIN MENU AND CALL OTHER
FUNCTIONS
//************************************************************************
*

void control :: main_menu(void)
{
void selected(int);
void toggle(int,int);
char m1[]="1: SEE ACCOUNT ",m2[]="2: LIST OF
ACCOUNTS",m3[]="3:TRANSACTIONS ",
m4[]="4: OPEN NEW ACCOUNT",m5[]="5: EDIT ACCOUNT
",m6[]="6: HELP",
m7[]="7: QUIT ";
static int counter=0;
while(1)
{
int gd=DETECT,gm=DETECT;
initgraph(&gd,&gm,"..gi");
counter++;
setfillstyle(1,7);
floodfill(320,240,1);
settextjustify(1,1);
setcolor(8);
settextstyle(7,0,0);
setusercharsize(27,10,5,3);
if (counter==1)
{
outtextxy(320,35,"B ");
delay(200);
outtextxy(320,35," A ");
delay(200);
outtextxy(320,35," N ");
delay(200);
outtextxy(320,35," K ");
delay(200);
outtextxy(320,35," I ");
delay(200);
outtextxy(320,35," N ");
delay(200);
outtextxy(320,35," G");
for(int i=0,j=640;i<610;i++,j--)
{
sound(2*i);
setcolor(8);
line(i,15,i-570,15);
line(j,65,j+570,65);
delay(5);
putpixel(i-570,15,7);
putpixel(j+570,65,7);
}
nosound();
}
else
{
setusercharsize(27,12,5,3);
outtextxy(320,35,"B A N K I N G");
setcolor(8);
line(610,15,40,15);
line(600,65,30,65);
}
settextstyle(7,1,5);
outtextxy(90,270,"O P T I O N S");
outtextxy(550,270,"O P T I O N S");
settextstyle(1,0,2);
char ch;
int choice=1,temp;
box(1,9);
box(2,7);
box(3,7);
box(4,7);
box(5,7);
box(6,7);
box(7,7);
setcolor(1);
outtextxy(320,90,m1);
setcolor(15);
outtextxy(320,150,m2);
outtextxy(320,210,m3);
outtextxy(320,270,m4);
outtextxy(320,330,m5);
outtextxy(320,390,m6);
outtextxy(320,450,m7);
//72 up
//80 down
//75 left
//77 right
//13 enter
//49 1
//71 Home
//79 End
//73 PgUp
//81 PgDown
//27 Escape
do
{
temp=choice;
ch=getch();
switch (ch)
{
case 72:
case 75:
choice=((--choice+7)%7);

toggle(choice,temp);

continue;
case 77:
case 80:
choice=(++choice%7);

toggle(choice,temp);

continue;
case 73:
choice=(choice+12)%7;

toggle(choice,temp);

break;
case 81:
choice=(choice+2)%7;

toggle(choice,temp);

break;
case 71:
case 49: choice=1;

toggle(choice,temp);

break;
case 50: choice=2;

toggle(choice,temp);

break;
case 51: choice=3;

toggle(choice,temp);

break;
case 52: choice=4;

toggle(choice,temp);

break;
case 53: choice=5;

toggle(choice,temp);

break;
case 54: choice=6;

toggle(choice,temp);

break;
case 79:
case 55: choice=0;

toggle(choice,temp);

break;
case 27: choice=0;

toggle(choice,temp);
case 13:
selected(choice);

delay(500);
}
}while (ch!=13&&ch!=27);
for(int i=320;i>0;i--)
{
if((counter==1)||(choice==0))
sound(3*i);
setcolor(1);
line(320-i,0,320-i,480);
line(320+i,0,320+i,480);
line(0,320-i,640,320-i);
line(0,160+i,640,160+i);
delay(2);
}
nosound();
closegraph();
if (choice == 1)
{
account a ;
a.display_account() ;
}
else
if (choice == 2)
{
initial ini ;
ini.display_list() ;
}
else
if (choice == 3)
{
account a ;
a.transaction() ;
}
else
if (choice == 4)
{
account a ;
a.new_account() ;
}
else
if (choice == 5)
edit_menu() ;
else
if (choice == 6)
help() ;
else
if (choice == 0)
{
break;
}
}
}
void toggle(int i,int temp)
{
char m1[]="1: SEE ACCOUNT ",m2[]="2: LIST OF
ACCOUNTS",m3[]="3:TRANSACTIONS ",
m4[]="4: OPEN NEW ACCOUNT",m5[]="5: EDIT ACCOUNT
",m6[]="6: HELP",
m7[]="7: QUIT ";
if (i==0) i=7;
if (temp==0) temp=7;
box(temp,7);
switch(temp)
{
case 1: box(1,7);
setcolor(15);
outtextxy(320,90,m1);
break;
case 2: box(2,7);
setcolor(15);
outtextxy(320,150,m2);
break;
case 3: box(3,7);
setcolor(15);
outtextxy(320,210,m3);
break;
case 4: box(4,7);
setcolor(15);
outtextxy(320,270,m4);
break;
case 5: box(5,7);
setcolor(15);
outtextxy(320,330,m5);
break;
case 6: box(6,7);
setcolor(15);
outtextxy(320,390,m6);
break;
case 7: box(7,7);
setcolor(15);
outtextxy(320,450,m7);
break;
}
switch(i)
{
case 1: box(1,9);
setcolor(1);
outtextxy(320,90,m1);
break;
case 2: box(2,9);
setcolor(1);
outtextxy(320,150,m2);
break;
case 3: box(3,9);
setcolor(1);
outtextxy(320,210,m3);
break;
case 4: box(4,9);
setcolor(1);
outtextxy(320,270,m4);
break;
case 5: box(5,9);
setcolor(1);
outtextxy(320,330,m5);
break;
case 6: box(6,9);
setcolor(1);
outtextxy(320,390,m6);
break;
case 7: box(7,9);
setcolor(1);
outtextxy(320,450,m7);
break;
}
}
void selected(int i)
{
if(i==0) i=7;
delay(350);
setcolor(0);
line(180,60*(i+.5)-20,180,60*(i+.5)+20);
line(180,60*(i+.5)-20,460,60*(i+.5)-20);
setcolor(15);
line(460,60*(i+.5)-20,460,60*(i+.5)+20);
line(180,60*(i+.5)+20,460,60*(i+.5)+20);
line(461,60*(i+.5)-20,461,60*(i+.5)+21);
line(180,60*(i+.5)+21,461,60*(i+.5)+21);
delay(350);
setcolor(15);
line(180,60*(i+.5)-20,180,60*(i+.5)+20);
line(180,60*(i+.5)-20,460,60*(i+.5)-20);
setcolor(0);
line(460,60*(i+.5)-20,460,60*(i+.5)+20);
line(180,60*(i+.5)+20,460,60*(i+.5)+20);
line(461,60*(i+.5)-20,461,60*(i+.5)+21);
line(180,60*(i+.5)+21,461,60*(i+.5)+21);
}
void box(int i,int color)
{
setcolor(5);
line(180,60*(i+.5)-20,180,60*(i+.5)+20);
line(180,60*(i+.5)-20,460,60*(i+.5)-20);
line(460,60*(i+.5)-20,460,60*(i+.5)+20);
line(180,60*(i+.5)+20,460,60*(i+.5)+20);
setfillstyle(1,color);
floodfill(320,60*(i+.5),5);
setcolor(15);
line(180,60*(i+.5)-20,180,60*(i+.5)+20);
line(180,60*(i+.5)-20,460,60*(i+.5)-20);
setcolor(0);
line(460,60*(i+.5)-20,460,60*(i+.5)+20);
line(180,60*(i+.5)+20,460,60*(i+.5)+20);
line(461,60*(i+.5)-20,461,60*(i+.5)+21);
line(180,60*(i+.5)+21,461,60*(i+.5)+21);
}
//************************************************************************
// CLASS CONTROL :: FUNCTION TO DISPLAY EDIT MENU AND CALL OTHER
FUNCTIONS
//************************************************************************

void control :: edit_menu(void)
{
char ch ;
while (1)
{
clrscr() ;
shape s ;
s.box(10,5,71,21,219) ;
s.box(9,4,72,22,218) ;
textcolor(BLACK) ;
textbackground(WHITE) ;
gotoxy(34,10) ;
cprintf(" EDIT MENU ") ;
textcolor(LIGHTGRAY) ;
textbackground(BLACK) ;
gotoxy(31,12) ;
cout <<"1: MODIFY ACCOUNT" ;
gotoxy(31,13) ;
cout <<"2: CLOSE ACCOUNT" ;
gotoxy(31,14) ;
cout <<"0: QUIT" ;
gotoxy(31,16) ;
cout <<"Enter your choice: " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
{
initial ini ;
ini.modify() ;
break ;
}
else
if (ch == '2')
{
account a ;
a.close_account() ;
break ;
}
else
if (ch == '0')
break ;
}
}

//**********************************************************
// CLASS CONTROL :: FUNCTION TO DISPLAY HELP ABOUT PROJECT
//**********************************************************
void control :: help(void)
{
clrscr() ;
shape s ;
s.box(2,1,79,25,218) ;
s.box(25,2,54,4,219) ;
textcolor(LIGHTBLUE+BLINK) ;
gotoxy(27,3); cprintf("WELCOME TO PROJECT BANKING") ;
delay(10) ;
gotoxy(10,5); cout <<" IN THIS PROJECT YOU CAN
KEEP RECORD FORDAILY ";
delay(10) ;
gotoxy(10,6); cout <<" BANKING TRANSACTIONS.
"
;
delay(10) ;
gotoxy(10,8); cout <<"- THIS PROGRAM IS CAPABLE OF HOLDING ANY No.
OF
ACCOUNTS";
delay(10) ;
gotoxy(10,10); cout <<"-1.) In the first option the account of a
particular person";
delay(10) ;
gotoxy(10,11); cout <<" is displayed by giving simply the account no.
of
that person." ;
delay(10) ;
gotoxy(10,13); cout <<"-2.) In second option you can see the list of
all the accounts." ;
delay(10) ;
gotoxy(10,15); cout <<"-3.) Through third option you can do banking
transactions" ;
delay(10) ;
gotoxy(10,16); cout <<" (Deposit/Withdraw)." ;
delay(10) ;
gotoxy(10,18); cout <<"-4.) In Fourth option you can open new
account."
;
delay(10) ;
gotoxy(10,19); cout <<" (NOTE: Opening amount i.e. , the first
deposit
should not be " ;
delay(10) ;
gotoxy(10,20); cout <<" less than Rs.500/-";
delay(10);
gotoxy(10,22); cout <<"-5.) In Fifth option you can Modify or Delete
any
account." ;
delay(10) ;
gotoxy(10,23); cout <<"-6.) In sixth option the help menu is
displayed
";
gotoxy(10,24); cout <<"-0.) This is the last option i.e., Quit (Exit
to
Dos). " ;
delay(10) ;
textcolor(RED+BLINK) ; textbackground(WHITE+BLINK) ;
gotoxy(26,25) ; cprintf(" Press a key to continue ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(25,2) ;
getch() ;
getch() ;
for (int i=25; i>=1; i--)
{
delay(20) ;
gotoxy(1,i) ; clreol() ;
}
}
//******************************************************************
// CLASS INITIAL :: THIS FUNCTION RETURN LAST ACCOUNT NO. IN THE FILE
// INITIAL.DAT
//******************************************************************
int initial :: last_accno(void)
{
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(initial)))
count = accno ;
file.close() ;
return count ;
}

//************************************************************************
*
// CLASS INITIAL :: THIS FUNCTION RETURN RECORD NO. OF THE GIVEN
ACCOUNT
NO.
// IN THE FILE INITIAL.DAT
//************************************************************************
*

int initial :: recordno(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(initial)))
{
count++ ;
if (t_accno == accno)
break ;
}
file.close() ;
return count ;
}

//************************************************************************
// CLASS I NITIAL :: THIS FUNCTION DISPLAY THE ACCOUNT FOR GIVEN
ACCOUNT
NO.
// FROM THE FILE INITIAL.DAT
//************************************************************************

void initial :: display(int t_accno)
{
shape s ;
s.box(8,7,73,11,219) ;
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(initial)))
{
if (t_accno == accno)
{
gotoxy(8,5) ;
cout <<"ACCOUNT NO. " < gotoxy(10,8) ;
cout <<"Name : " < gotoxy(10,9) ;
cout <<"Address : " <
gotoxy(10,10) ;
cout <<"Balance : " < break ;
}
}
file.close() ;
}

//*********************************************************************
// CLASS INITIAL :: THIS FUNCTION RETURN NAME FOR THE GIVEN ACCOUNT NO.
// IN THE FILE INITIAL.DAT
//*********************************************************************

char *initial :: return_name(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
char t_name[30] ;
while (file.read((char *) this, sizeof(initial)))
{
if (accno == t_accno)
{
strcpy(t_name,name) ;
break ;
}
}
file.close() ;
return t_name ;
}

//************************************************************************
// CLASS INITIAL :: THIS FUNCTION RETURN ADDRESS FOR THE GIVEN ACCOUNT
NO.
// IN THE FILE INITIAL.DAT
//************************************************************************

char *initial :: return_address(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
char t_address[60] ;
while (file.read((char *) this, sizeof(initial)))
{
if (accno == t_accno)
{
strcpy(t_address,address) ;
break ;
}
}
file.close() ;
return t_address ;
}

//************************************************************************
// CLASS INITIAL :: THIS FUNCTION RETURN BALANCE FOR THE GIVEN ACCOUNT
NO.
// IN THE FILE INITIAL.DAT
//************************************************************************

float initial :: give_balance(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
float t_balance ;
while (file.read((char *) this, sizeof(initial)))
{
if (accno == t_accno)
{
t_balance = balance ;
break ;
}
}
file.close() ;
return t_balance ;
}

//***********************************************************************
// CLASS INITIAL :: THIS FUNCTION RETURN 1 IF THE GIVEN ACCOUNT NO.
FOUND
// IN THE FILE INITIAL.DAT
//***********************************************************************

int initial :: found_account(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(initial)))
{
if (accno == t_accno)
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}

//**********************************************************************
// CLASS INITIAL :: THIS FUNCTION DRAWS THE BOX FOR THE LIST OF
ACCOUNTS
//**********************************************************************

void initial :: box_for_list()
{
shape s ;
s.box(2,1,79,25,218) ;
s.line_hor(3,78,3,196) ;
s.line_hor(3,78,5,196) ;
s.line_hor(3,78,23,196) ;
textbackground(WHITE) ;
gotoxy(3,4) ;
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(4,4) ;
cprintf("ACCOUNT NO. NAME OF PERSON BALANCE")
;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
gotoxy(4,2) ;
cout <<"Date: " <}

//**********************************************************************
// CLASS INITIAL :: THIS FUNCTION DISPLAYS THE LIST OF ACCOUNTS IN FILE
// INITIAL.DAT
//**********************************************************************

void initial :: display_list(void)
{
clrscr() ;
box_for_list() ;
int row=6, flag ;
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
while (file.read((char *) this, sizeof(initial)))
{
flag = 0 ;
delay(10) ;
gotoxy(7,row) ;
cout < gotoxy(25,row) ;
cout < gotoxy(57,row) ;
cout < row++ ;
if (row == 23)
{
flag = 1 ;
row = 6 ;
gotoxy(4,24) ;
cout <<"Press any key to continue..." ;
getch() ;
clrscr() ;
box_for_list() ;
}
}
file.close() ;
if (!flag)
{
gotoxy(4,24) ;
cout <<"Press any key to continue..." ;
getch() ;
}
}

//*****************************************************************
// CLASS INITIAL :: THIS FUNCTION ADDS THE GIVEN DATA INTO THE FILE
// INITIAL.DAT
//*****************************************************************
void initial :: add_to_file(int t_accno, char t_name[30], char
t_address[60], float t_balance)
{
accno = t_accno ;
strcpy(name,t_name) ;
strcpy(address,t_address) ;
balance = t_balance ;
fstream file ;
file.open("INITIAL.DAT", ios::out | ios::app|ios::binary) ;
file.write((char *) this, sizeof(initial)) ;
file.close() ;
}

//***********************************************************************
// CLASS INITIAL :: THIS FUNCTION DELETES RECORD FOR THE GIVEN ACOUNT
NO.
// FROM THE FILE INITIAL.DAT
//***********************************************************************

void initial :: delete_account(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in|ios::binary) ;
fstream temp ;
temp.open("temp.dat", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(initial)) ;
if ( file.eof() )
break ;
if ( accno != t_accno )
temp.write((char *) this, sizeof(initial)) ;
}
file.close() ;
temp.close() ;
file.open("INITIAL.DAT", ios::out|ios::binary) ;
temp.open("temp.dat", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(initial)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(initial)) ;
}
file.close() ;
temp.close() ;
}

//************************************************************************
// CLASS INITIAL :: THIS FUNCTION UPDATE BALANCE FOR THE GIVEN ACOUNT
NO.
// IN THE FILE INITIAL.DAT
//************************************************************************

void initial :: update_balance(int t_accno, float t_balance)
{
int recno ;
recno = recordno(t_accno) ;
fstream file ;
file.open("INITIAL.DAT", ios::out | ios::ate|ios::binary) ;
balance = t_balance ;
int location ;
location = (recno-1) * sizeof(initial) ;
file.seekp(location) ;
file.write((char *) this, sizeof(initial)) ;
file.close() ;
}

//**********************************************************************
// CLASS INITIAL :: THIS FUNCTION MODIFIES THE RECORD FOR THE GIVEN
DATA
// IN THE FILE INITIAL.DAT
//**********************************************************************

void initial :: modify_account(int t_accno, char t_name[30], char
t_address[60])
{
int recno ;
recno = recordno(t_accno) ;
fstream file ;
file.open("INITIAL.DAT", ios::out | ios::ate|ios::binary) ;
strcpy(name,t_name) ;
strcpy(address,t_address) ;
int location ;
location = (recno-1) * sizeof(initial) ;
file.seekp(location) ;
file.write((char *) this, sizeof(initial)) ;
file.close() ;
}

//************************************************************************
//CLASS INITIAL :: THIS FUNCTION GIVE THE DATA TO MODIFY THE RECORD IN
THE
// FILE INITIAL.DAT
//************************************************************************

void initial :: modify(void)
{
clrscr() ;
char t_acc[10] ;
int t, t_accno ;
gotoxy(1,1) ;
cout <<"PRESS (0) TO EXIT" ;
gotoxy(5,5) ;
cout <<"Enter the account no. " ;
gets(t_acc) ;
t = atoi(t_acc) ;
t_accno = t ;
if (t_accno == 0)
return ;
clrscr() ;
if (!found_account(t_accno))
{
gotoxy(5,5) ;
cout <<"7Account not found" ;
getch() ;
return ;
}
shape s ;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(1,1) ;
cout <<"PRESS (0) TO EXIT" ;
textbackground(WHITE) ;
gotoxy(3,3) ;
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(30,3) ;
cprintf("MODIFY ACCOUNT SCREEN") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
int d1, m1, y1 ;
struct date d;
getdate(&d); //Inbuilt
function to display current
d1 = d.da_day ;
//date
of the system
m1 = d.da_mon ;
y1 = d.da_year ;
gotoxy(62,5) ;
cout <<"Date: "<<<"/" < char ch ;
display(t_accno) ;
account a ;
do
{
a.clear(5,13) ;
gotoxy(5,13) ;
cout <<"Modify this account (y/n): " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
int modified=0, valid ;
char t_name[30], t_address[60] ;
gotoxy(5,15) ;
cout <<"Name : " ;
gotoxy(5,16) ;
cout <<"Address : " ;
do
{
a.clear(15,15) ;
a.clear(5,23) ;
gotoxy(5,23) ;
cout <<"ENTER NAME or PRESS FOR NO CHANGE" ;
valid = 1 ;
gotoxy(15,15) ;
gets(t_name) ;
strupr(t_name) ;
if (t_name[0] == '0')
return ;
if (strlen(t_name) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7NAME SHOULD NOT BE GREATER THAN 25") ;
getch() ;
}
} while (!valid) ;
if (strlen(t_name) > 0)
modified = 1 ;
do
{
a.clear(15,16) ;
a.clear(5,23) ;
gotoxy(5,23) ;
cout <<"ENTER ADDRESS or PRESS FOR NO CHANGE" ;
valid = 1;
gotoxy(15,16) ;
gets(t_address) ;
strupr(t_address) ;
if (t_address[0] == '0')
return ;
if (strlen(t_address) > 55)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7SHOULD NOT BE BLANK OR GREATER THAN 55") ;
getch() ;
}
} while (!valid) ;
if (strlen(t_address) > 0)
modified = 1 ;
if (!modified)
return ;
a.clear(5,23) ;
do
{
a.clear(5,18) ;
gotoxy(5,18) ;
cout <<"Do you want to save changes (y/n): " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
modify_account(t_accno,t_name,t_address) ;
gotoxy(5,21) ;
cout <<"7Record Modified" ;
gotoxy(5,23) ;
cout <<"press a key to continue..." ;
getch() ;
}

//****************************************************************
// CLASS ACCOUNT :: THIS FUNCTION CLEAR THE GIVEN ROW AND COLUMNS
//****************************************************************
void account :: clear(int col, int row)
{
for (int i=col; i<=78; i++)
{
gotoxy(i,row) ;
cout <<" " ;
}
}

//*****************************************************************
// CLASS ACCOUNT :: THIS FUNCTION ADDS THE GIVEN DATA INTO THE FILE
// BANKING.DAT
//*****************************************************************
void account :: add_to_file(int t_accno, int d1, int m1, int y1, char
t_tran, char t_type[10], float t_interest, float t_amount, float
t_balance)
{
fstream file ;
file.open("BANKING.DAT", ios::app|ios::binary) ;
accno = t_accno ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
tran = t_tran ;
strcpy(type,t_type) ;
interest = t_interest ;
amount = t_amount ;
balance = t_balance ;
file.write((char *) this, sizeof(account)) ;
file.close() ;
}

//************************************************************************

// CLASS ACCOUNT :: THIS FUNCTION DELETES THE RECORD FOR GIVIN ACCOUNT
NO.
// FROM FILE BANKING.DAT
//************************************************************************


void account :: delete_account(int t_accno)
{
fstream file ;
file.open("BANKING.DAT", ios::in|ios::binary) ;
fstream temp ;
temp.open("temp.dat", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(account)) ;
if ( file.eof() )
break ;
if ( accno != t_accno )
temp.write((char *) this, sizeof(account)) ;
}
file.close() ;
temp.close() ;
file.open("BANKING.DAT", ios::out|ios::binary) ;
temp.open("temp.dat", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(account)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(account)) ;
}
file.close() ;
temp.close() ;
}

//**********************************************************
// THIS FUNCTION ACCEPTS THE DATA TO ADD RECORDS IN THE
// FILE BANKING.DAT
//**********************************************************
void account :: new_account(void)
{
char ch ;
int i, valid ;
clrscr() ;
initial ini ;
shape s ;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(71,1) ;
cout <<"<0>=Exit" ;
textbackground(WHITE) ;
gotoxy(3,3) ;
for (i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(32,3) ;
cprintf("OPEN NEW ACCOUNT") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
int t_accno ;
t_accno = ini.last_accno() ;
t_accno++ ;
if (t_accno == 1)
{
ini.add_to_file(t_accno,"abc","xyz",1.1) ;
ini.delete_account(t_accno) ;
add_to_file(t_accno,1,1,1997,'D',"INITIAL",1.1,1.1,1.1) ;
delete_account(t_accno) ;
}
char t_name[30], t[10], t_address[60] ;
float t_bal=0.0, t_balance=0.0 ;
gotoxy(5,6) ;
cout <<"Date : "<<<"/" < gotoxy(5,8) ;
cout <<"Account no. # " < gotoxy(5,10) ;
cout <<"Name : " ;
gotoxy(5,11) ;
cout <<"Address : " ;
gotoxy(5,12) ;
cout <<"Name of Verifying person : " ;
gotoxy(5,14) ;
cout <<"Initial Deposit : " ;
do
{
clear(15,10) ;
clear(5,23) ;
gotoxy(5,23) ;
cout <<"ENTER NAME OF THE PERSON" ;
valid = 1 ;
gotoxy(15,10) ;
gets(t_name) ;
strupr(t_name) ;
if (t_name[0] == '0')
return ;
if (strlen(t_name) == 0 || strlen(t_name) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7NAME SHOULD NOT BE BLANK OR GREATER THAN 25") ;
getch() ;
}
} while (!valid) ;
do
{
clear(15,11) ;
clear(5,23) ;
gotoxy(5,23) ;
cout <<"ENTER ADDRESS OF THE PERSON" ;
valid = 1 ;
gotoxy(15,11) ;
gets(t_address) ;
strupr(t_address) ;
if (t_address[0] == '0')
return ;
if (strlen(t_address) == 0 || strlen(t_address) > 55)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7SHOULD NOT BLANK OR GREATER THAN 55") ;
getch() ;
}
} while (!valid) ;
do
{
char vari[30] ;
clear(31,12) ;
clear(5,23) ;
gotoxy(5,23) ;
cout <<"ENTER NAME OF THE VERIFING PERSON" ;
valid = 1 ;
gotoxy(31,12) ;
gets(vari) ;
strupr(vari) ;
if (vari[0] == '0')
return ;
if (strlen(vari) == 0 || strlen(vari) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7SHOULD NOT BLANK OR GREATER THAN 25") ;
getch() ;
}
} while (!valid) ;
do
{
clear(23,14) ;
clear(5,23) ;
gotoxy(5,23) ;
cout <<"ENTER INITIAL AMOUNT TO BE DEPOSIT" ;
valid = 1 ;
gotoxy(23,14) ;
gets(t) ;
t_bal = atof(t) ;
t_balance = t_bal ;
if (t[0] == '0')
return ;
if (t_balance < 500)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7SHOULD NOT LESS THAN 500 ") ;
getch() ;
}
} while (!valid) ;
clear(5,23) ;
do
{
clear(5,17) ;
valid = 1 ;
gotoxy(5,17) ;
cout <<"Do you want to save the record (y/n) : " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
float t_amount, t_interest ;
t_amount = t_balance ;
t_interest = 0.0 ;
char t_tran, t_type[10] ;
t_tran = 'D' ;
strcpy(t_type,"INITIAL") ;
ini.add_to_file(t_accno,t_name,t_address,t_balance) ;
add_to_file(t_accno,d1,m1,y1,t_tran,t_type,t_interest,t_amount,t_balance)
;
}


//**********************************************************
// THIS FUNCTION DRAWS THE BOX FOR DISPLAYING RECORD FROM
// FILE BANKING.DAT
//**********************************************************
void account :: box_for_display(int t_accno)
{
shape s ;
s.box(2,1,79,25,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,6,196) ;
s.line_hor(3,78,23,196) ;
textbackground(WHITE) ;
gotoxy(3,5) ;
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(4,5) ;
cprintf("DATE PARTICULAR DEPOSIT
WITHDRAW INTEREST BALANCE") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
gotoxy(63,2) ;
cout <<"Date: " <<<"/" < gotoxy(4,2) ;
cout <<"Account no. " < initial ini ;
char t_name[30] ;
strcpy(t_name,ini.return_name(t_accno)) ;
char t_address[60] ;
strcpy(t_address,ini.return_address(t_accno)) ;
gotoxy(25,2) ;
cout < gotoxy(25,3) ;
cout <}

//**********************************************************
// THIS FUNCTION DISPLAY RECORD FROM THE FILE BANKING.DAT
//**********************************************************
void account :: display_account(void)
{
clrscr() ;
char t_acc[10] ;
int t, t_accno ;
gotoxy(1,1) ;
cout <<"PRESS (0) TO EXIT" ;
gotoxy(5,5) ;
cout <<"Enter the account no. " ;
gets(t_acc) ;
t = atoi(t_acc) ;
t_accno = t ;
if (t_accno == 0)
return ;
clrscr() ;
initial ini ;
if (!ini.found_account(t_accno))
{
gotoxy(5,5) ;
cout <<"7Account not found" ;
getch() ;
return ;
}
box_for_display(t_accno) ;
int row=7, flag = 0 ;
fstream file ;
file.open("BANKING.DAT", ios::in|ios::binary) ;
while (file.read((char *) this, sizeof(account)))
{
if (accno == t_accno)
{
flag = 0 ;
delay(10) ;
gotoxy(4,row) ;
cout <
< gotoxy(16,row) ;
cout < if (tran == 'D')
gotoxy(30,row) ;
else
gotoxy(42,row) ;
cout < gotoxy(56,row) ;
cout < gotoxy(66,row) ;
cout < row++ ;
if (row == 23)
{
flag = 1 ;
row = 7 ;
gotoxy(4,24) ;
cout <<"press a key to continue..." ;
getch() ;
clrscr() ;
box_for_display(t_accno) ;
}
}
}
file.close() ;
if (!flag)
{
gotoxy(4,24) ;
cout <<"press a key to continue..." ;
getch() ;
}
}

//**********************************************************
// THIS FUNCTION RETURNS THE DIFFERENCE BETWEEN 2 DATES.
//**********************************************************
int account :: no_of_days(int d1, int m1, int y1, int d2, int m2, int
y2)
{
static int month[] = {31,28,31,30,31,30,31,31,30,31,30,31} ;
int days = 0 ;
while (d1 != d2 || m1 != m2 || y1 != y2)
{
days++ ;
d1++ ;
if (d1 > month[m1-1])
{
d1 = 1 ;
m1++ ;
}
if (m1 > 12)
{
m1 = 1 ;
y1++ ;
}
}
return days ;
}

//**********************************************************
// THIS FUNCTION CALCULATES INTEREST.
//**********************************************************
float account :: calculate_interest(int t_accno, float t_balance)
{
fstream file ;
file.open("BANKING.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int d1, m1, y1, days ;
while (file.read((char *) this, sizeof(account)))
{
if (accno == t_accno)
{
d1 = dd ;
m1 = mm ;
y1 = yy ;
break ;
}
}
int d2, m2, y2 ;
struct date d;
getdate(&d);
d2 = d.da_day ;
m2 = d.da_mon ;
y2 = d.da_year ;
float t_interest=0.0 ;
if ((y2&& d2 return t_interest ;
days = no_of_days(d1,m1,y1,d2,m2,y2) ;
int months=0 ;
if (days >= 30)
{
months = days/30 ;
t_interest = ((t_balance*2)/100) * months ;
}
file.close() ;
return t_interest ;
}

//**********************************************************
// THIS FUNCTION MAKES TRANSACTIONS (DEPOSIT/WITHDRAW).
//**********************************************************
void account :: transaction(void)
{
clrscr() ;
char t_acc[10] ;
int t, t_accno, valid ;
gotoxy(1,1) ;
cout <<"PRESS (0) TO EXIT" ;
gotoxy(5,5) ;
cout <<"Enter the account no. " ;
gets(t_acc) ;
t = atoi(t_acc) ;
t_accno = t ;
if (t_accno == 0)
return ;
clrscr() ;
initial ini ;
if (!ini.found_account(t_accno))
{
gotoxy(5,5) ;
cout <<"7Account not found" ;
getch() ;
return ;
}
shape s ;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(1,1) ;
cout <<"PRESS (0) TO EXIT" ;
textbackground(WHITE) ;
gotoxy(3,3) ;
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("TRANSACTION IN ACCOUNT") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
gotoxy(5,6) ;
cout <<"Date : "<<<"/" < gotoxy(5,8) ;
cout <<"Account no. # " < char t_name[30] ;
char t_address[60] ;
float t_balance ;
strcpy(t_name,ini.return_name(t_accno)) ;
strcpy(t_address,ini.return_address(t_accno)) ;
t_balance = ini.give_balance(t_accno) ;
s.box(25,10,75,13,218) ;
gotoxy(27,11) ;
cout <<"Name : " < gotoxy(27,12) ;
cout <<"Address: " < gotoxy(5,15) ;
cout <<"Last Balance : Rs." < char t_tran, t_type[10], tm[10] ;
float t_amount, t_amt ;
do
{
clear(5,18) ;
valid = 1 ;
gotoxy(5,18) ;
cout <<"Deposit or Withdraw (D/W) : " ;
t_tran = getche() ;
if (t_tran == '0')
return ;
t_tran = toupper(t_tran) ;
} while (t_tran != 'D' && t_tran != 'W') ;
do
{
clear(5,19) ;
clear(5,23) ;
gotoxy(5,23) ;
cout <<"ENTER TRANSACTION BY CASH OR CHEQUE" ;
valid = 1 ;
gotoxy(5,19) ;
cout <<"(Cash/Cheque) : " ;
gets(t_type) ;
strupr(t_type) ;
if (t_type[0] == '0')
return ;
if (strcmp(t_type,"CASH") &&
strcmp(t_type,"CHEQUE"))
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7ENTER CORRECTLY ") ;
getch() ;
}
} while (!valid) ;
do
{
clear(5,21) ;
clear(5,23) ;
gotoxy(5,23) ;
cout <<"ENTER AMOUNT FOR TRANSACTION" ;
valid = 1 ;
gotoxy(5,21) ;
cout <<"Amount : Rs." ;
gets(tm) ;
t_amt = atof(tm) ;
t_amount = t_amt ;
if (tm[0] == '0')
return ;
if ((t_tran == 'W' && t_amount > t_balance) || (t_amount < 1))
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7INVALID DATA ENTERED ") ;
getch() ;
}
} while (!valid) ;
char ch ;
clear(5,23) ;
do
{
clear(40,20) ;
valid = 1 ;
gotoxy(40,20) ;
cout <<"Save transaction (y/n): " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
float t_interest ;
t_interest = calculate_interest(t_accno,t_balance) ;
if (t_tran == 'D')
t_balance = t_balance + t_amount + t_interest ;
else
t_balance = (t_balance - t_amount) + t_interest ;
ini.update_balance(t_accno,t_balance) ;
add_to_file(t_accno,d1,m1,y1,t_tran,t_type,t_interest,t_amount,t_balance)
;
}

//**********************************************************
// THIS FUNCTION CLOSE THE ACCOUNT (DELETE ACCOUNT).
//**********************************************************
void account :: close_account(void)
{
clrscr() ;
char t_acc[10] ;
int t, t_accno ;
gotoxy(1,1) ;
cout <<"PRESS (0) TO EXIT" ;
gotoxy(5,5) ;
cout <<"Enter the account no. " ;
gets(t_acc) ;
t = atoi(t_acc) ;
t_accno = t ;

if (t_accno == 0)
return ;
clrscr() ;
initial ini ;
if (!ini.found_account(t_accno))
{
gotoxy(5,5) ;
cout <<"7Account not found" ;
getch() ;
return ;
}
shape s ;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(1,1) ;
cout <<"PRESS (0) TO EXIT" ;
textbackground(WHITE) ;
gotoxy(3,3) ;
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(30,3) ;
cprintf("CLOSE ACCOUNT SCREEN") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
gotoxy(62,5) ;
cout <<"Date: "<<<"/" < char ch ;
ini.display(t_accno) ;
do
{
clear(5,15) ;
gotoxy(5,15) ;
cout <<"Close this account (y/n): " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
ini.delete_account(t_accno) ;
delete_account(t_accno) ;
gotoxy(5,20) ;
cout <<"7Record Deleted" ;
gotoxy(5,23) ;
cout <<"press a key to continue..." ;
getch() ;
}

//************************************************************
// THIS IS MAIN FUNCTION CALLING HELP AND MAIN MENU FUNCTIONS
//************************************************************
void main(void)
//Main segment
{ int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "..gi");

gra1();
gra2();
control c ;
c.help() ;
c.main_menu() ;
}
//*************************************************************
// INDIVIDUAL FUNCTION DEFINITIONS
//*************************************************************
void gra1()
//Function definition #1
{
clrscr();
char msg[33];
int gdriver=DETECT,gmode,errorcode,c1x,c2x,c3x,c4x,c5x,c6x;
int c1y,c2y,c3y,c4y,c5y,c6y;
c1x=c2x=270; // c1 c3
c3x=c4x=370; // c5 c6
c5x=220;c6x=420; // c2 c4
c1y=c3y=20;
c2y=c4y=120;
c5y=c6y=70;
initgraph (&gdriver, &gmode," c: c");
setfillstyle(1,8);
setcolor(8);
line(0,300,640,300);
floodfill(320,240,8);
setcolor(4);
line(c1x,c1y,c2x,c2y);
line(c1x,c1y,c3x,c3y);
line(c1x,c1y,c4x,c4y);
line(c2x,c2y,c3x,c3y);
line(c2x,c2y,c4x,c4y);
line(c3x,c3y,c4x,c4y);
line(c1x,c1y,c5x,c5y);
line(c5x,c5y,c2x,c2y);
line(c3x,c3y,c6x,c6y);
line(c4x,c4y,c6x,c6y); //DRAW
THE LOGO OF UDAY
setfillstyle(1,4);
floodfill(320,72,4);
floodfill(320,68,4);
floodfill(240,70,4);
floodfill(400,70,4);
setfillstyle(1,15);
floodfill(300,70,4);
floodfill(340,70,4);
settextjustify(1,1);
settextstyle(10,0,7);
setcolor(15);
outtextxy(230,200,"");
outtextxy(290,200,"");
//TO WRITE UDAY
outtextxy(350,200,"");
outtextxy(410,200,"");
setfillstyle(9,7);
floodfill(410,250,15);
floodfill(225,215,15);
floodfill(275,210,15);
floodfill(350,215,15); //TO FILL THE
LETTERS
UDAY
floodfill(390,210,15);
floodfill(423,205,15);
floodfill(423,230,15);
floodfill(270,244,15);
floodfill(300,200,15);
setcolor(15);
line (320-150,320-13,320+150,320-13);
line (320-150,320+12,320+150,320+12);
line (320-150,320-13,320-150,320+12);
line (320+150,320+12,320+150,320-13);
int s=30,w;
gotoxy(20,23);
cout<<"LOADING . . .";
for (int
x1=171,x2=171,y1=308,y2=331,y=1,S=0;x1<470;x1++,x2++,y++,S++)
{
setcolor(4);
line (x1,y1,x2,y2);
w=(x1-169)/3;
for (int i=34; i<=37; i++)
{
gotoxy(i,23) ;
cout <<" " ;
}
gotoxy(34,23); cout< if (x2>270) s=45; if (x2>370) s=10;
if (x2==320) delay(999); else
delay(s);
}
delay(800);
for (int i=27; i<=37; i++)
{
gotoxy(i,23) ;
cout <<" " ;
}
gotoxy(28,23);
cout<<"COMPLETE"; gotoxy(20,25);
cout<<"PRESS ANY KEY TO CONTINUE ";
getch();
cleardevice();
}
void gra2() //Function definition *2
{
clrscr(); //To make a designer ellipse
int gd=DETECT,gm;
initgraph(&gd, &gm, "c: c");
setcolor(8);
ellipse(320,240,0,360,300,150);
settextstyle(10,0,4);
settextjustify(1,1);
setcolor(5);
outtextxy(320,170,"PROJECT BANKING");
delay(250);
settextstyle(4,0,4);
setcolor(20);
outtextxy(320,220,"Presented By:");
delay(250);
outtextxy(320,315,"ISIT");
settextstyle(10,0,4);
setcolor(3);
delay(250);
outtextxy(320,265,"INTELLIGENTS");
for (int stangle=0;!kbhit();stangle++)
{
setcolor(7);
ellipse(320,240,stangle,stangle+20,300,150);
ellipse(320,240,stangle+180,stangle+200,300,150);
delay(9);
setcolor(8);
ellipse(320,240,stangle-1,stangle+19,300,150);
ellipse(320,240,stangle-1+180,stangle+199,300,150);
}
closegraph();
}


!!!... Election Voting Software ...!!!

!!!... Election Voting Software ...!!!

Well this is the project which i made in 12th , 3 yrs back. It took me 2 mnths to complete this project but in the end all was running fine. This Program wen runned (ignore 8 warnings ) in Turbo C++ asks for a password which i have initally set to "divakar" and u can change it . After that it displays a menu. Since their are no database of candidates and voters initally so you have to first edit and enter the records of candidates and voters and den start voting. Remember this " for evry time u run the program u have enter the details of candidates n voters and this database is temporary..".. for any problems contact..

//**********************************************************
// PROJECT ELECTION-VOTING SOFTWARE
//**********************************************************


/* THIS PROJECT IS MADE BY DIVAKAR GILANI OF CLASS XII-C */


//**********************************************************
// INCLUDED HEADER FILES
//**********************************************************



#include
#include
#include
#include
#include
#include
#include
#include
#include


char description()
{ delay(2000);
cout<<"\t\t ELECTION VOTING SOFTWARE \n\n";
delay(500);
cout<<"\t DESCRIPTION : IN THIS PROJECT , A PREDETERMINED SET OF \n\n\n";
delay(500);
cout<<"\t VOTERS WILL BE ABLE TO CAST THE VOTE .VOTERS WILL HAVE \n\n\n";
delay(500);
cout<<"\t TO PROVE THEIR IDENTITY BY GIVING THEIR IDENTIFICATION \n\n\n";
delay(500);
cout<<"\t NO. A AUTHENTICATED USER WILL BE ABLE TO CAST THE VOTE.\n\n\n";
delay(500);
cout<<"\t A USER WHO HAS CASTED THE VOTE CANNOT CAST AGAIN.AFTER \n\n\n";
delay(500);
cout<<"\t VOTING HAS FINISHED RESUTS WILL BE DECLAIR. A SETUP \n\n\n";
delay(500);
cout<<"\t OPTION BEFORE ELECTION STARTS , WILL ALLOW VOTER TO BE \n\n\n";
delay(500);
cout<<"\t CREATED AND CANDIDATE CHOOSEN. \n\n\n";
delay(1500);
cout<<"\n\n\n\t\t\tPLEASE PRESS ENTER TO CONTINUE & Esc. TO EXIT\t";
char ch;
for(;;)
{
ch=getch();
if(ch==13)
break;
else
if(ch==27)
exit(-1);
else
cout<<"\n\n\t\t\t\a ! WRONG KEY ENTERED !";
delay(300);
cout<<"\n\n\n\n\t\t\t PRESS ENTER ";
}
return 0;
}

int pass()
{
char ch;
int r=0;
char pass[20];
for(;;)
{
clrscr();
gotoxy(16,20);
cout<<"Enter the password to initialize the setup :";
r=0;
for(int i=0;;i++)
{
ch=getch();

if(ch==13)
{ pass[r]='\0';
break;
}

if(ch==8)
{

if(i>0)
{ cout<i-=2;r--;
}
else
i--;
}
else
{ cout<<"*";
pass[r]=ch;
r++;
}
}
if(strcmp("divakar",pass)==0)
return 0;
else
{
cout<<"\n\n\t\t\a!! INVALID PASSWORD !!";
delay(300);
cout<<"\n\n\t\t--> TRY AGAIN";
getch();
}
}
}



//**********************************************************
// THIS FUNCTION TRUE WHEN THE STRING PASSED AS ARGUMENT IS
// IS NUMBER
//**********************************************************

int string_is_number(char* s)
{
int size = strlen(s);
for(int i = 0; i < size; i++)
if (!(s[i] >= '0' && s[i] <= '9'))
return 0;
return 1;
}

class candidate_record
{
public:
int candidate_namecode ;
char candidate_name[50] ;
char partyname[50], partysign[50] ;
char summary[1];
char revenue[100];
char age[100];
char area[50];
};

class voter_record
{
public:
int voter_namecode ;
char voter_name[50] ;
char age[10], gender[10] ;
};

class voter_status
{
public:
int voter_namecode;
int voting_status;
};

class candidate_status
{
public:
int candidate_namecode;
int numVotes;
};


//**********************************************************
// CLASS NAME : vote
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
// RELATED TO VOTING ITEMS
//**********************************************************

class vote
{
public :
void add_candidate_name(void) ;
void delete_candidate_name(void) ;
void modify_candidate_name(void) ;
void list_of_candidate_names(void) ;
void voting(void) ;

void add_voter_name(void) ;
void delete_voter_name(void) ;
void modify_voter_name(void) ;
void list_of_voters_names(void) ;
private :
int last_candidate_code(int &num_candidates) ;
void delete_candidate_record(int) ;
void modify_candidate_record(int) ;
void display_candidate_record(int) ;
int name_candidate_found(int) ;
int candidate_recordno(int, candidate_record&) ;
void candidate_sort(void) ;


int last_voter_code(int &num_voters) ;
void delete_voter_record(int) ;
void modify_voter_record(int) ;
void display_voter_record(int) ;
int name_voter_found(int) ;
int voter_recordno(int, voter_record &vr) ;
void voter_sort(void) ;
voter_status* init_voter_status(int &num);
candidate_status* init_candidate_status(int &num);
} ;


//**********************************************************
// CLASS NAME : menu
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
//**********************************************************
class menu
{
public :
void main_menu(void) ;
private :
void edit_menu(void) ;
vote v;
} ;


//**********************************************************
// THIS FUNCTION CREATE MAIN MENU AND CALLS OTHER FUNCTIONS
//**********************************************************

void menu :: main_menu(void)
{
clrscr() ;
char ch ;
while (1)
{
clrscr();
gotoxy(27,4) ;
cout<<" E L E C T I O N ";
gotoxy(27,6);
cout <<" V O T I N G S O F T W A R E " ;
gotoxy(31,8) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(32,9) ;
cout <<"1: VOTE " ;
gotoxy(32,11) ;
cout <<"2: SEE MENU " ;
gotoxy(32,13) ;
cout <<"3: EDIT " ;
gotoxy(32,17) ;
cout <<"0: QUIT " ;
gotoxy(32,20) ;
cout <<"Enter Choice : " ;
ch = getche() ;
if (ch == 27)
return ;
else
if (ch == '1')
{
vote v ;
v.voting() ;
}
else

if (ch == '2')
{
vote v ;
v.list_of_candidate_names() ;
gotoxy(1,20) ;
cout <<"Press any key to see the voters details" ;
getche() ;

v.list_of_voters_names();
}
else
if (ch == '3')
edit_menu() ;

else
if (ch == '0')
break ;
}
}


//**********************************************************
// THIS FUNCTION CREATE EDIT MENU AND CALLS OTHER FUNCTIONS
//**********************************************************

void menu :: edit_menu(void)
{
clrscr();
char ch,choice;
cout<<" \EDIT \MENU \n\n";

cout<<" 1: \* EDIT CANDIDATE RECORD \*\n";

cout<<" 2: \* EDIT VOTER RECORD \*\n";

cout<<" 0: \* EXIT \*\n";
cout<<" \ENTER \CHOICE: ";
choice = getche();
if (choice == '1')
{
while(1)
{
gotoxy(28,10) ;
cout <<" * EDIT CANDIDATE RECORD *" ;
gotoxy(28,12) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(28,14) ;
cout <<"1: * \ADD \CANDIDATE \NAME * " ;
gotoxy(28,16) ;
cout <<"2: * \MODIFY \CANDIDATE \NAME *" ;
gotoxy(28,18) ;
cout <<"3: * \DELETE \CANDIDATE \NAME *" ;
gotoxy(28,20) ;
cout <<"0: * \EXIT *" ;
gotoxy(28,22) ;
cout <<" ENTER CHOICE: " ;
ch = getche() ;
if (ch == '1')
{
vote v ;
v.add_candidate_name() ;
break ;
}
else if (ch == '2')
{
vote v ;
v.modify_candidate_name() ;
break ;
}
else if (ch == '3')
{
vote v ;
v.delete_candidate_name() ;
break ;
}
else
if (ch == '0')
break ;
}
}
if(choice=='2')
{
while (1)
{
gotoxy(28,10) ;
cout <<" * EDIT VOTER RECORD *" ;
gotoxy(28,12) ;
cout <<" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(28,14) ;
cout <<"1: * \ADD \VOTER \NAME * " ;
gotoxy(28,16) ;
cout <<"2: * \MODIFY \VOTER \NAME * " ;
gotoxy(28,18) ;
cout <<"3: * \DELETE \VOTER \NAME * " ;
gotoxy(28,20) ;
cout <<"0: * EXIT " ;
gotoxy(28,22) ;
cout <<"Enter Choice: " ;
ch = getche() ;
if (ch == '1')
{
vote v ;
v.add_voter_name() ;
break ;
}
else if (ch == '2')
{
vote v ;
v.modify_voter_name() ;
break ;
}
else if (ch == '3')
{
vote v ;
v.delete_voter_name() ;
break ;
}
else if (ch == '0')
break ;
}
}
}




//**********************************************************
// THIS FUNCTION RETURNS THE CODE OF THE LAST RECORD OF THE
// VOTER IN THE VOTER FILE (VOTER.DAT).
//**********************************************************

int vote :: last_voter_code(int &num_voters)
{
voter_record vr;
fstream file ;
num_voters = 0;
file.open("VOTER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int t=0 ;
while (file.read((char *)&vr,sizeof(voter_record)))
{
t = vr.voter_namecode ;
num_voters++;
}
file.close() ;
return t ;
}


//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF THE NAMES OF VOTERS
//**********************************************************

void vote :: list_of_voters_names(void)
{
clrscr() ;
voter_record vr;
fstream file ;
file.open("VOTER.DAT", ios::in|ios::binary) ;
file.seekg(0) ;
int row = 6 , found = 0 , pageno = 1 ;
gotoxy(30,2) ;
cout <<"LIST OF NAMES OF VOTERS" ;
gotoxy(29,3) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(3,4) ;
cout <<"NAME CODE NAME AGE GENDER" ;
gotoxy(2,5) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
while (file.read((char *)&vr, sizeof(voter_record)))
{
delay(20) ;
found = 1 ;
gotoxy(5,row) ;
cout <gotoxy(14,row) ;
cout <gotoxy(37,row) ;
cout <gotoxy(51,row) ;
cout <if ( row == 22 )
{
row = 5 ;
gotoxy(66,1) ;
cout <<"Page no. : " <gotoxy(66,2) ;
cout <<"===============" ;
pageno++ ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
clrscr() ;
gotoxy(3,4) ;
cout << "NAME CODE NAME AGE GENDER " ;
gotoxy(2,5) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
}
else
row++ ;
}
if ( !found )
{
gotoxy(5,10) ;
cout <<"\7Records not found " ;
}
gotoxy(66,1) ;
cout <<"Page no. : " <gotoxy(66,2) ;
cout <<"===============" ;
gotoxy(1,20) ;
cout <<"Press any key to continue..." ;
getche() ;
file.close () ;
}


//**********************************************************
// THIS FUNCTION ADD RECORDS IN THE VOTER FILE (VOTER.DAT)
//**********************************************************

void vote :: add_voter_name(void)
{
voter_record vr;
int vcode, valid ;
char ch;
int num_voters;
vcode = last_voter_code(num_voters) ;
vcode++ ;
do
{
clrscr() ;
gotoxy(71,2) ;
cout <<"<0>=Exit" ;
gotoxy(23,3) ;
cout <<" ADD NAME TO THE VOTER LIST" ;
gotoxy(23,4) ;
cout <<" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(5,6) ;
cout <<"Name Code : " <gotoxy(5,8) ;
cout <<"Name: " ;
gotoxy(5,10) ;
cout <<"Age: " ;
gotoxy(5,12) ;
cout <<"Gender: " ;
do
{
valid = 1 ;
gotoxy(1,8) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER NAME OF THE VOTER TO ADD IN THE LIST" ;
gotoxy(5,8) ;
cout <<" Name : " ;
gets(vr.voter_name) ;
strupr(vr.voter_name) ;
if (vr.voter_name[0] == '0')
return ;
if ((strlen(vr.voter_name) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = A...Z" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(1,10) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER AGE OF VOTER TO ADD IN THE LIST" ;
gotoxy(5,10) ;
cout <<"Age : " ;
gets(vr.age) ;
strupr(vr.age);
if (vr.age[0] == '0')
return ;
if ((strlen(vr.age) <> 3 ) || (!string_is_number(vr.age)))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = 18...100" ;
getch() ;
}
if (atoi(vr.age) < 18)
{
valid = 0;
gotoxy(3,24);
cout <<"\7 Voter's age is less than 18";
getch();
}

} while (!valid) ;
do
{
valid = 1 ;
gotoxy(1,12) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER GENDER OF VOTER TO ADD IN THE MENU" ;
gotoxy(5,12) ;
cout <<"GENDER : " ;
gets(vr.gender) ;
strupr(vr.gender);
if (vr.gender[0] == '0')
return ;
if ((strlen(vr.gender) <> 1)
|| (strcmp(vr.gender,"M") && strcmp(vr.gender,"F")))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = M/F" ;
getch() ;
}
} while (!valid) ;
do
{
gotoxy(1,15) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(5,15) ;
cout <<"Do you want to save this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'Y')
{
vr.voter_namecode = vcode ;
fstream file ;
file.open("VOTER.DAT", ios::out | ios::app |ios::binary) ;
file.write((char *)&vr, sizeof(voter_record)) ;
file.close() ;
vcode++ ;
}
do
{
gotoxy(1,17) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(5,17) ;

cout <<"Do you want to add more records (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
} while (ch == 'Y') ;
}


//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD OF THE GIVEN CODE FROM
// THE VOTER FILE (VOTER.DAT)
//**********************************************************

void vote :: display_voter_record(int vcode)
{
voter_record vr;
fstream file ;
file.open("VOTER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
while (file.read((char *)&vr, sizeof(voter_record)))
{
if (vr.voter_namecode == vcode)
{
gotoxy(5,3) ;
cout <<"Name Code : "<gotoxy(5,4) ;
cout <<"Name : "<gotoxy(5,5) ;
cout <<"Age : "<gotoxy(5,6) ;
cout <<"Gender : "<break ;
}
}
file.close() ;
}


//**********************************************************
// THIS FUNCTION RETURN THE VALUE 1 IF THE RECORD IS FOUND
// FOR THE GIVEN CODE IN THE VOTER FILE (VOTER.DAT)
//**********************************************************

int vote :: name_voter_found(int tcode)
{
voter_record vr;
fstream file ;
file.open("VOTER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *)&vr, sizeof(voter_record)))
{
if (vr.voter_namecode == tcode)
{
found++ ;
break ;
}
}
file.close() ;
return found ;
}


//**********************************************************
// THIS FUNCTION RETURN THE RECORD NO. OF THE GIVEN CODE IN
// THE VOTER FILE (VOTER.DAT)
//**********************************************************

int vote :: voter_recordno(int tcode, voter_record &vr)
{
voter_record temp;
fstream file ;
file.open("VOTER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *)&temp, sizeof(voter_record)))
{
found++ ;
if (temp.voter_namecode == tcode)
{
vr = temp;
break ;
}
}
file.close() ;
return found ;
}


//**********************************************************
// THIS FUNCTION DELETES THE RECORD FOR THE GIVEN CODE FROM
// THE VOTER FILE (VOTER.DAT)
//**********************************************************

void vote :: delete_voter_record(int tcode)
{
voter_record vr;
fstream file ;
file.open("VOTER.DAT", ios::in|ios::binary) ;
fstream temp ;
temp.open("temp.dat", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *)&vr, sizeof(voter_record)) ;
if ( file.eof() )
break ;
if ( vr.voter_namecode != tcode )
temp.write((char *)&vr, sizeof(voter_record)) ;
}
file.close() ;
temp.close() ;
file.open("VOTER.DAT", ios::out|ios::binary) ;
temp.open("temp.dat", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *)&vr, sizeof(voter_record)) ;
if ( temp.eof() )
break ;
file.write((char *)&vr, sizeof(voter_record)) ;
}
file.close() ;
temp.close() ;
}


//**********************************************************
// THIS FUNCTION GIVES THE CODE NO. TO DELETE RECORD FROM
// THE VOTER FILE (VOTER.DAT)
//**********************************************************

void vote :: delete_voter_name(void)
{
clrscr() ;
char t_code[5], ch ;
int tcode ;
gotoxy(3,25) ;
cout <<"Press to see the list" ;
gotoxy(5,3) ;
cout <<"Enter Name Code of the item to be deleted : " ;
gets(t_code) ;
tcode = atoi(t_code) ;
if (tcode == 0)
{
list_of_voters_names() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"Press to Exit" ;
gotoxy(5,24) ;
cout <<"Enter Name Code of the item to be deleted : " ;
gets(t_code) ;
tcode = atoi(t_code) ;
if (tcode == 0)
return ;
}
clrscr() ;
if (!name_voter_found(tcode))
{
gotoxy(5,5) ;
cout <<"\7Record not found" ;
getch() ;
return ;
}
display_voter_record(tcode) ;
do
{
gotoxy(1,8) ; clreol() ;
gotoxy(5,8) ;
cout <<"Do you want to delete this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
delete_voter_record(tcode) ;
gotoxy(5,15) ;
cout <<"\7Record Deleted" ;
getch() ;
}


//**********************************************************
// THIS FUNCTION MODIFY THE RECORD FOR THE GIVEN CODE FROM
// THE VOTER FILE (VOTER.DAT)
//**********************************************************

void vote :: modify_voter_record(int tcode)
{
voter_record vr;
int recno ;
recno = voter_recordno(tcode,vr) ;

if (recno == 0)
return;
int valid, t_code ;
char ch,t_namecode[5] ;
gotoxy(71,2) ;
cout <<"<0>=Exit" ;
gotoxy(5,12) ;
cout <<"Name Code : " ;
gotoxy(5,14) ;
cout <<" Name : " ;
gotoxy(5,16) ;
cout <<" Age : " ;
gotoxy(5,18) ;
cout <<"Gender: " ;
do
{
gotoxy(20,12) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,12) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER NAME CODE TO ADD IN THE MENU" ;
gotoxy(5,12) ;
cout <<"Name Code : " ;
gets(t_namecode) ;
vr.voter_namecode = atoi(t_namecode) ;
if (vr.voter_namecode == 0)
return ;
if (name_voter_found(vr.voter_namecode) && vr.voter_namecode != tcode)
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 CODE ALREADY GIVEN" ;
getch() ;
}
}
do
{
gotoxy(20,14) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,14) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER NAME TO ADD IN THE MENU" ;
gotoxy(5,14) ;
cout <<" Name : " ;
gets(vr.voter_name) ;
strupr(vr.voter_name) ;
if (vr.voter_name[0] == '0')
return ;
if ((strlen(vr.voter_name) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = 1..50" ;
getch() ;
}
}
do
{
gotoxy(20,16) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,16) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER AGE OF VOTER TO ADD IN THE MENU" ;
gotoxy(5,16) ;
cout <<"Age : " ;
gets(vr.age) ;
strupr(vr.age);
if (vr.age[0] == '0')
return ;
if ((strlen(vr.age) <> 10) || !string_is_number(vr.age))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = 1..10" ;
getch() ;
}
}
do
{
gotoxy(20,18) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,18) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER GENDER OF VOTER TO ADD IN THE MENU" ;
gotoxy(5,18) ;
cout <<"Gender : " ;
gets(vr.gender) ;
strupr(vr.gender);
if (vr.gender[0] == '0')
return ;
if ((strlen(vr.gender) <> 10))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = " <getch() ;
}
}
do
{
gotoxy(1,21) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(5,21) ;
cout <<"Do you want to save this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;

getch() ;
fstream file ;
file.open("VOTER.DAT", ios::out | ios::ate|ios::binary) ;
int location ;
location = (recno-1) * sizeof(vr) ;
cout << " Location is " << location;
file.seekp(location) ;
file.write((char *) &vr, sizeof(voter_record)) ;
file.close() ;
voter_sort() ;
clrscr() ;
gotoxy(5,15) ;
cout <<"\7Record Modified" ;
getch() ;
}


//**********************************************************
// THIS FUNCTION GIVES THE CODE NO. TO MODIFY RECORD FROM
// THE VOTER FILE (VOTER.DAT)
//**********************************************************

void vote :: modify_voter_name(void)
{
clrscr() ;
char t_code[5], ch ;
int tcode ;
gotoxy(3,25) ;
cout <<"Press to see the list" ;
gotoxy(5,3) ;
cout <<"Enter Name Code of the item to be Modify : " ;
gets(t_code) ;
tcode = atoi(t_code) ;
if (tcode == 0)
{
list_of_voters_names() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"Press to Exit" ;
gotoxy(5,24) ;
cout <<"Enter Name Code of the item to be modify : " ;
gets(t_code) ;
tcode = atoi(t_code) ;
if (tcode == 0)
return ;
}
clrscr() ;
if (!name_voter_found(tcode))
{
gotoxy(5,5) ;
cout <<"\7Record not found" ;
getch() ;
return ;
}
display_voter_record(tcode) ;
do
{
gotoxy(5,8) ;
cout <<"Do you want to Modify this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
modify_voter_record(tcode) ;
}



//**********************************************************
// THIS FUNCTION SORT THE RECORD IN THE VOTER FILE (VOTER.DAT)
// ACCORDING TO THE CODE NOS.
//**********************************************************

void vote :: voter_sort(void)
{
int i=0,j ;
voter_record *arr, temp ;
fstream file ;
file.open("VOTER.DAT", ios::in|ios::binary) ;


//*************************************************************
// COUNT THE NUMBER OF RECORDS IN THE FILE
//************************************************************
while (file.read((char *) &temp, sizeof(voter_record)))
i++ ;
file.clear();



//*************************************************************
// CREATE AN ARRAY TO HOD ALL THE RECORDS
//*************************************************************
arr = (voter_record*) new voter_record[i];
int size ;
size = i ;


//*************************************************************
// SEEK THE FIE BACK TO THE BEGINNING
//*************************************************************
file.seekg(0,ios::beg) ;

//*************************************************************
// READ THE RECORDS FROM THE FILE TO THE ARRAY
//*************************************************************
for( i = 0; i < size; i++)
file.read((char*)&(arr[i]),sizeof(voter_record));
file.close() ;

for (i=1; i{
for (j=0; j{
if (arr[j].voter_namecode > arr[j+1].voter_namecode)
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}

file.open("VOTER.DAT", ios::out|ios::binary) ;

for (i=0; ifile.write((char *) &arr[i], sizeof(voter_record));
delete[] arr;

file.close() ;
}



//**********************************************************
// THIS FUNCTION IS THE MAIN FUNCTION CALLING THE MAIN MENU
//**********************************************************

void main(void)
{
clrscr() ;
char des;
description();
// exit();
clrscr();
char p;
pass();
clrscr();
menu m ;
m.main_menu() ;

}



//**********************************************************
// THIS FUNCTION SORT THE RECORD IN THE CANDIDATE FILE (CANDIDATE.DAT)
// ACCORDING TO THE CODE NOS.
//**********************************************************


void vote :: candidate_sort(void)
{
int i=0,j ;
candidate_record *arr, temp ;
fstream file ;
file.open("CANDIDATE.DAT", ios::in|ios::binary) ;

while (file.read((char *) &temp, sizeof(candidate_record)))
i++ ;

file.clear();

arr = (candidate_record*) new candidate_record[i];

int size ;
size = i ;

file.seekg(0,ios::beg) ;

for( i = 0; i < size; i++)
file.read((char*)&arr[i],sizeof(candidate_record));

file.close() ;

for (i=1; i{
for (j=0; j{
if (arr[j].candidate_namecode > arr[j+1].candidate_namecode)
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}

file.open("CANDIDATE.DAT", ios::out|ios::binary) ;

for (i=0; ifile.write((char *) &arr[i], sizeof(candidate_record));
delete[] arr;

file.close() ;
}


//**********************************************************
// THIS FUNCTION GIVES THE CODE NO. TO MODIFY RECORD FROM
// THE CANDIDATE FILE (CANDIDATE.DAT)
//**********************************************************

void vote :: modify_candidate_name(void)
{
clrscr() ;
char t_code[5], ch ;
int tcode ;
gotoxy(3,25) ;
cout <<"Press to see the list" ;
gotoxy(5,3) ;
cout <<"Enter Name Code of the item to be Modify : " ;
gets(t_code) ;
tcode = atoi(t_code) ;
if (tcode == 0)
{
list_of_candidate_names() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"Press to Exit" ;
gotoxy(5,24) ;
cout <<"Enter Name Code of the item to be modify : " ;
gets(t_code) ;
tcode = atoi(t_code) ;
if (tcode == 0)
return ;
}
clrscr() ;
if (!name_candidate_found(tcode))
{
gotoxy(5,5) ;
cout <<"\7Record not found" ;
getch() ;
return ;
}
display_candidate_record(tcode) ;
do
{
gotoxy(5,8) ;
cout <<"Do you want to Modify this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
modify_candidate_record(tcode) ;
}


//**********************************************************
// THIS FUNCTION MODIFY THE RECORD FOR THE GIVEN CODE FROM
// THE CANDIDATE FILE (CANDIDATE.DAT)
//**********************************************************

void vote :: modify_candidate_record(int tcode)
{
candidate_record cr;
int recno ;
int revenue;
recno = candidate_recordno(tcode,cr) ;
int valid, t_code ;
char ch,t_namecode[5] ;
gotoxy(71,2) ;
cout <<"<0>=Exit" ;
gotoxy(5,12) ;
cout <<"Name Code : " ;
gotoxy(5,14) ;
cout <<" Name : " ;
gotoxy(5,16) ;
cout <<" Party Name : " ;
gotoxy(5,18) ;
cout <<"Party Sign: " ;
gotoxy(5,20) ;
cout <<"Summary : " ;
do
{
gotoxy(20,12) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,12) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER NAME CODE TO ADD IN THE MENU" ;
gotoxy(5,12) ;
cout <<"Name Code : " ;
gets(t_namecode) ;
cr.candidate_namecode = atoi(t_namecode) ;
if (cr.candidate_namecode == 0)
return ;
if (name_candidate_found(cr.candidate_namecode) && cr.candidate_namecode != tcode)
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 CODE ALREADY GIVEN" ;
getch() ;
}
}
do
{
gotoxy(20,14) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,14) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER NAME TO ADD IN THE MENU" ;
gotoxy(5,14) ;
cout <<" Name : " ;
gets(cr.candidate_name) ;
strupr(cr.candidate_name) ;
if (cr.candidate_name[0] == '0')
return ;
if ((strlen(cr.candidate_name) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = 1..50" ;
getch() ;
}
}
do
{
gotoxy(20,16) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,16) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER PARTY NAME TO ADD IN THE MENU" ;
gotoxy(5,16) ;
cout <<"Party Name : " ;
gets(cr.partyname) ;
strupr(cr.partyname);
if (cr.partyname[0] == '0')
return ;
if ((strlen(cr.partyname) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = 1..50" ;
getch() ;
}
}
do
{
gotoxy(20,18) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,18) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER PARTY SIGN TO ADD IN THE MENU" ;
gotoxy(5,18) ;
cout <<"Party Sign : " ;
gets(cr.partysign) ;
strupr(cr.partysign);


if (cr.partysign[0] == '0')
return ;
if ((strlen(cr.partysign) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = " <getch() ;
}
}
do
{
gotoxy(20,20) ; clreol() ;
cout <<"Change (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
valid = 0 ;
while (ch == 'Y' && !valid)
{
valid = 1 ;
gotoxy(1,20) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE SUMMARY OF THE CANDIDATE" ;
gotoxy(5,20) ;
cout <<"Summary declared: " ;
gets(cr.summary) ;
strupr(cr.summary);


if (cr.summary[0] == '0')
return ;
if ((strlen(cr.summary) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = " <getch() ;
}
}
do
{
gotoxy(1,21) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(5,21) ;
cout <<"Do you want to save this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
getch() ;
fstream file ;
file.open("CANDIDATE.DAT", ios::out | ios::ate|ios::binary) ;
int location ;
location = (recno-1) * sizeof(cr) ;
file.seekp(location) ;
file.write((char *) &cr, sizeof(candidate_record)) ;
file.close() ;
candidate_sort() ;
clrscr() ;
gotoxy(5,15) ;
cout <<"\7Record Modified" ;
getch() ;
}


//**********************************************************
// THIS FUNCTION RETURN THE VALUE 1 IF THE RECORD IS FOUND
// FOR THE GIVEN CODE IN THE CANDIDATE FILE (CANDIDATE.DAT)
//**********************************************************

int vote :: name_candidate_found(int tcode)
{
candidate_record cr;
fstream file ;
file.open("CANDIDATE.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *)&cr, sizeof(candidate_record)))
{
if (cr.candidate_namecode == tcode)
{
found++ ;
break ;
}
}
file.close() ;
return found ;
}


//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD OF THE GIVEN CODE FROM
// THE CANDIDATE FILE (CANDIDATE.DAT)
//**********************************************************

void vote :: display_candidate_record(int tcode)
{ candidate_record cr;
fstream file ;
file.open("CANDIDATE.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
while (file.read((char *)&cr, sizeof(candidate_record)))
{
if (cr.candidate_namecode == tcode)
{
gotoxy(5,3) ;
cout <<"Name Code : "<gotoxy(5,4) ;
cout <<"Name : "<gotoxy(5,5) ;
cout <<"Party Name : "<gotoxy(5,6) ;
cout <<"Party Sign : "<gotoxy(5,7) ;
cout <<"Revenue : "<gotoxy(5,8) ;
cout <<"Age : "<gotoxy(5,9) ;
cout <<"Area : "<break ;
}
}
file.close() ;
}


//**********************************************************
// THIS FUNCTION ADD RECORDS IN THE CANDIDATE FILE (CANDIDATE.DAT)
//**********************************************************

void vote :: add_candidate_name(void)
{
candidate_record cr;
int tcode, valid ;
char ch;
int num_candidates;
tcode = last_candidate_code(num_candidates) ;
tcode++ ;
do
{
clrscr() ;
gotoxy(71,2) ;
cout <<"<0>=Exit" ;
gotoxy(27,3) ;
cout <<" ADD NAME TO THE CANDIDATE LIST" ;
gotoxy(26,4) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(5,6) ;
cout <<"Name Code : " <gotoxy(5,8) ;
cout <<"Name : " ;
gotoxy(5,10) ;
cout <<"Party Name : " ;
gotoxy(5,12) ;
cout <<"Party Sign : " ;
gotoxy(5,14) ;
cout <<"Summary : " ;
do
{
valid = 1 ;
gotoxy(1,8) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER NAME TO ADD IN THE CANDIDATE LIST" ;
gotoxy(5,8) ;
cout <<"Name : " ;
gets(cr.candidate_name) ;
strupr(cr.candidate_name) ;
if (cr.candidate_name[0] == '0')
return ;
if ((strlen(cr.candidate_name) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = A.....Z" ;
getch() ;
}
}while (!valid) ;
do
{
valid = 1 ;
gotoxy(1,10) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(5,25) ;
cout <<"ENTER PARTY NAME TO ADD IN THE LIST" ;
gotoxy(5,10) ;
cout <<"Party Name : " ;
gets(cr.partyname) ;
strupr(cr.partyname);
if (cr.partyname[0] == '0')
return ;
if ((strlen(cr.partyname) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = A.....Z" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(1,12) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;

gotoxy(5,25) ;
cout <<"ENTER PARTY SIGN TO ADD IN THE MENU" ;
gotoxy(5,12) ;
cout <<"Party Sign : " ;
gets(cr.partysign) ;
strupr(cr.partysign);
if (cr.partysign[0] == '0')
return ;
if ((strlen(cr.partysign) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = A.....Z" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1;
gotoxy(1,14) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;

gotoxy(5,25) ;
cout <<"ENTER SUMMARY OF THE CANDIDATE" ;
gotoxy(5,14) ;
cout <<"SUMMARY AS FOLLOWS " ;
getch();
// gets(cr.summary) ;
strupr(cr.summary);
if (cr.summary[0] == '0')
return ;
if ((strlen(cr.summary) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = A.....Z" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1;
gotoxy(1,16) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;

gotoxy(5,25) ;
cout <<"ENTER REVENUE OF THE CANDIDATE" ;
gotoxy(5,16) ;
cout <<"Revenue : " ;
gets(cr.revenue) ;
strupr(cr.revenue);
if (cr.revenue[0] == '0')
return ;
if ((strlen(cr.revenue) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = A.....Z" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1;
gotoxy(1,18) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;

gotoxy(5,25) ;
cout <<"ENTER AGE OF THE CANDIDATE" ;
gotoxy(5,18) ;
cout <<"Age : " ;
gets(cr.age) ;
strupr(cr.age);
if (cr.age[0] == '0')
return ;
if ((strlen(cr.age) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = A.....Z" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1;
gotoxy(1,20) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;

gotoxy(5,25) ;
cout <<"ENTER AREA OF THE CANDIDATE" ;
gotoxy(5,20) ;
cout <<"Area : " ;
gets(cr.area) ;
strupr(cr.area);
if (cr.area[0] == '0')
return ;
if ((strlen(cr.area) <> 50))
{
valid = 0 ;
gotoxy(3,24) ;
cout <<"\7 Range = A.....Z" ;
getch() ;
}
} while (!valid) ;
do
{
gotoxy(1,15) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(5,28) ;
cout <<"Do you want to save this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'Y')
{
cr.candidate_namecode = tcode ;
fstream file ;
file.open("CANDIDATE.DAT", ios::out | ios::app | ios::binary) ;
file.write((char *)&cr, sizeof(candidate_record)) ;
file.close() ;
tcode++ ;
}
do
{
gotoxy(1,17) ; clreol() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(5,30) ;
cout <<"Do you want to add more records (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
} while (ch == 'Y') ;
}


//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF THE NAMES OF CANDIDATES
//**********************************************************

void vote :: list_of_candidate_names(void)
{
clrscr() ;

candidate_record cr;
fstream file ;
file.open("CANDIDATE.DAT", ios::in|ios::binary) ;
file.seekg(0) ;
int row = 6 , found = 0 , pageno = 1 ;
gotoxy(30,2) ;
cout <<"LIST OF NAMES OF CANDIDATES" ;
gotoxy(29,3) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(3,4) ;
cout <<"NAME CODE NAME PARTY NAME PARTY SIGN REVENUE AGE AREA";
gotoxy(2,5) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
while (file.read((char *)&cr, sizeof(candidate_record)))
{
delay(20) ;
found = 1 ;
gotoxy(5,row) ;
cout <gotoxy(14,row) ;
cout <gotoxy(31,row) ;
cout <gotoxy(45,row) ;
cout <gotoxy(58,row) ;
cout <gotoxy(69,row) ;
cout <gotoxy(75,row) ;
cout <if ( row == 22 )
{
row = 5 ;
gotoxy(66,1) ;
cout <<"Page no. : " <gotoxy(66,2) ;
cout <<"===============" ;
pageno++ ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
clrscr() ;
gotoxy(3,4) ;
cout << "NAME CODE NAME PARTY NAME PARTY SIGN REVENUE AGE AREA" ;
gotoxy(2,5) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
}
else
row++ ;
}
if ( !found )
{
gotoxy(5,10) ;
cout <<"\7Records not found " ;
}
gotoxy(66,1) ;
cout <<"Page no. : " <gotoxy(66,2) ;
cout <<"===============" ;
gotoxy(1,20) ;
cout <<"Press any key to continue..." ;
getche() ;
file.close () ;
}



//**********************************************************
// THIS FUNCTION RETURNS THE CODE OF THE LAST RECORD IN THE
// CANDIDATE FILE (CANDIDATE.DAT).
//**********************************************************

int vote :: last_candidate_code(int &num_candidates)
{
candidate_record cr;
fstream file ;
num_candidates = 0;
file.open("CANDIDATE.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int t=0 ;
while (file.read((char *) &cr, sizeof(candidate_record)))
{
t = cr.candidate_namecode ;
num_candidates++;
}
file.close() ;
return t ;
}



//**********************************************************
// THIS FUNCTION RETURN THE RECORD NO. OF THE GIVEN CODE IN
// THE CANDIDATE FILE (CANDIDATE.DAT)
//**********************************************************

int vote :: candidate_recordno(int tcode,candidate_record &cr)
{
candidate_record temp;
fstream file ;
file.open("CANDIDATE.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) &temp, sizeof(candidate_record)))
{
found++ ;
if (temp.candidate_namecode == tcode)
{
cr = temp;
break ;
}
}
file.close() ;
return found ;
}



//**********************************************************
// THIS FUNCTION DELETES THE RECORD FOR THE GIVEN CODE FROM
// THE CANDIDATE FILE (CANDIDATE.DAT)
//**********************************************************

void vote :: delete_candidate_record(int tcode)
{
candidate_record cr;
fstream file ;
file.open("CANDIDATE.DAT", ios::in|ios::binary) ;
fstream temp ;
temp.open("temp.dat", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *)&cr, sizeof(candidate_record)) ;
if ( file.eof() )
break ;
if ( cr.candidate_namecode != tcode )
temp.write((char *)&cr, sizeof(candidate_record)) ;
}
file.close() ;
temp.close() ;
file.open("CANDIDATE.DAT", ios::out|ios::binary) ;
temp.open("temp.dat", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *)&cr, sizeof(candidate_record)) ;
if ( temp.eof() )
break ;
file.write((char *) &cr, sizeof(candidate_record)) ;
}
file.close() ;
temp.close() ;
}



//**********************************************************
// THIS FUNCTION GIVES THE CODE NO. TO DELETE RECORD FROM
// THE CANDIDATE FILE (CANDIDATE.DAT)
//**********************************************************

void vote :: delete_candidate_name(void)
{
clrscr() ;
char t_code[5], ch ;
int tcode ;
gotoxy(3,25) ;
cout <<"Press to see the list" ;
gotoxy(5,3) ;
cout <<"Enter Name Code of the item to be deleted : " ;
gets(t_code) ;
tcode = atoi(t_code) ;

if (tcode == 0)
{
list_of_candidate_names() ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"Press 0 to EXIT" ;
gotoxy(5,24) ;
cout <<"Enter Name Code of the item to be deleted : " ;
gets(t_code) ;
tcode = atoi(t_code) ;
if (tcode == 0)
return ;
}
clrscr() ;
if (!name_candidate_found(tcode))
{
gotoxy(5,5) ;
cout <<"\7Record not found" ;
getch() ;
return ;
}
display_candidate_record(tcode) ;
do
{
gotoxy(1,8) ; clreol() ;
gotoxy(5,8) ;
cout <<"Do you want to delete this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
delete_candidate_record(tcode) ;
gotoxy(5,15) ;
cout <<"\7Record Deleted" ;
getch() ;
}

voter_status* vote::init_voter_status(int &num)
{
voter_status *vs = NULL;
num = 0;
last_voter_code(num);
if (num != 0)
{
vs = new voter_status[num];
voter_record vr;
fstream file ;
file.open("VOTER.DAT", ios::in|ios::binary) ;
for(int i = 0; i < num; i++)
{
file.read((char *)&vr, sizeof(voter_record));
vs[i].voter_namecode = vr.voter_namecode;
vs[i].voting_status = 0;
}
file.close();
}
return vs;
}
candidate_status* vote::init_candidate_status(int &num)
{
candidate_status *cs = NULL;;
num = 0;
last_candidate_code(num);
if (num != 0)
{
cs = new candidate_status[num];
candidate_record cr;
fstream file;
file.open("CANDIDATE.DAT",ios::in|ios::binary);
for(int i = 0; i < num; i++)
{
file.read((char *)&cr, sizeof(candidate_record));
cs[i].candidate_namecode = cr.candidate_namecode;
cs[i].numVotes = 0;
}
file.close();
}
return cs;

}



void vote::voting()
{
clrscr() ;

char ch,name[50];
int n ,num_voters = 0, num_candidates = 0;
int vtr_rec;
voter_status* vs = init_voter_status(num_voters);
candidate_status* cs = init_candidate_status(num_candidates);
int valid=0;
if (num_voters == 0)
{
gotoxy(3,6);
cout << "There are NO VOTERS";
ch = getche();
delete[] vs;
delete[] cs;
return;
}
if (num_candidates == 0)
{
gotoxy(3,6);
cout << "There are NO CANDIDATES";
ch = getche();
delete[] vs;
delete[] cs;
return;
}

while(1)
{
clrscr();
gotoxy(30,2);
cout <<"VOTING HAS STARTED";
gotoxy(29,3);
cout <<"~~~~~~~~~~~~~~~~~~~~~~";

{
int i;
for(i = 0; i < num_voters; i++)
{
if (vs[i].voting_status == 0) break;
}
if (i == num_voters)
{
gotoxy(3,4);
cout<<"All VOTES have been casted";
getche();
break;
}

}

gotoxy(3,24) ;
clreol();
cout <<"To End the voting Enter .\n";
gotoxy(3,25);
clreol();
cout <<"Once voting is stopped it cann't resume. You will have to start a fresh" ;

gotoxy(6,3);
clreol();
cout <<"Enter the voter code - ";
gets(name);
if (strcmp(name,"STOP") == 0)
{
//Terminate the Voting;
gotoxy(6,5);
clreol();
cout <<"Do you want to STOP the voting and start counting votes (y/n) - ";
ch = getche();
ch = toupper(ch);
while(!(ch == 'Y' || ch == 'N'))
{
gotoxy(70,5);
clreol();
ch = getche();
ch = toupper(ch);
}
if (ch == 'N')
{
gotoxy(6,5);
clreol();
continue;
}
else break;
}

n = string_is_number(name);
gotoxy(6,5);
clreol();

if (n == 0)
{
cout << "Incorrect voter code, enter only digits, try again ";
getche();
continue;
}

n = atoi(name);
if (n == 0)
{
list_of_voters_names();
continue;
}


for(vtr_rec = 0; vtr_rec < num_voters; vtr_rec++)
{
if (vs[vtr_rec].voter_namecode == n)
{
if (vs[vtr_rec].voting_status == 1)
{
cout << "Voter with voter code "<< n <<" has alread voted";
}
getche();
break;
}
}
if ( vtr_rec == num_voters)
{
cout << "Voter code "<< n << " not found in Voter list";
getche();
continue;
}
if (vs[vtr_rec].voting_status == 1)
{
cout << "Voter code "<getche();
continue;
}

while(1)
{
clrscr();

gotoxy(3,24) ;
clreol();
cout<<"To cast invalid vote press ";

gotoxy(3,3);
cout <<"Voter with voter code " << vs[vtr_rec].voter_namecode<<" is voting";
gotoxy(3,4);
cout<<"Enter the candidate code -" ;

char can_code[50];
gets(can_code);

if (can_code[0] == 'Y' || can_code[0] == 'y')
{
vs[vtr_rec].voting_status = 1;
clrscr();
cout<<"Voter ";
gotoxy(3,7);
display_voter_record(vs[vtr_rec].voter_namecode);
gotoxy(3,8);
cout <<"has casted a invalid vote";
getche();
break;
}


int can = string_is_number(can_code);

gotoxy(3,6);
if (can == 0)
{
cout << "Incorrect candidate code, enter only digits, try again ";
getche();
continue;
}

can = atoi(can_code);
if (can == 0)
{
list_of_candidate_names();
getche();
continue;
}
int can_rec;
for(can_rec=0; can_rec{
if (cs[can_rec].candidate_namecode == can)
break;
}
if (can_rec == num_candidates)
{
cout <<"Candidate code "<getche();
continue;
}
cs[can_rec].numVotes++;
vs[vtr_rec].voting_status = 1;
clrscr();
gotoxy(3,6);

voter_record vr;
voter_recordno(vs[vtr_rec].voter_namecode, vr) ;

cout<<"Voter " << vr.voter_name<< " has voterd for Candidate ";

candidate_record cr;
candidate_recordno(cs[can_rec].candidate_namecode,cr);

cout << cr.candidate_name;

gotoxy(35,20);
cout<<"VOTE CASTED";
getche();
valid=1;
break;
}
}


if (valid)
{
clrscr();
gotoxy(20,9);
cout<<"VOTING RESULTS";
int tie =0;
int winner=0;
int max = 0;
int i;
for(i = 0; i < num_candidates; i++)
{
if (cs[i].numVotes > max)
{
max = cs[i].numVotes;
}
else if (cs[i].numVotes == max && max > 0)
tie = 1;
}

gotoxy(20,12);
if (tie) cout<<"Voting has resulted in tie, joint winners are";
else cout <<"WINNER is ";
gotoxy(20,13);
for(i = 0; i < num_candidates; i++)
{
if (cs[i].numVotes == max)
{

candidate_record cr;
candidate_recordno(cs[i].candidate_namecode,cr);
if (winner)
cout<<", ";
cout << "\n\n\t\t\t"<gotoxy(25,25);
cout<<"THE SUMMARY FOLLOWS";
delay(500);
gotoxy(25,27);
delay(500);
cout << "PARTY NAME -->"<gotoxy(25,29);
delay(500);
cout << "PARTY SIGN -->"<gotoxy(25,31);
delay(500);
cout << "REVENUE -->"<gotoxy(25,33);
delay(500);
cout << "AGE -->"<gotoxy(25,35);
delay(500);
cout << "AREA -->"<winner++;
}
}

}
ch = getche();
delete[] vs;
delete[] cs;
}