Monday, 21 August 2017

Pyramid with stars

#include<stdio.h>

void main()
{
    int row, c, n, temp;

    printf("Enter the number of rows in pyramid of stars you wish to see ");
    scanf("%d", &n);

    temp = n;

    for (row = 1; row <= n; row++)
    {
        for (c = 1; c < temp; c++)
            printf(" ");

        temp--;

        for (c = 1; c <= 2 * row - 1; c++)
            printf("*");

        printf("\n");
    }//loop end

    return 0;
}

System clock poject

#include<graphics.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm;
int x=320,y=240,r=200,i,h,m,s,thetamin,thetasec;
struct  time t;
char n[12][3]={"3","2","1","12","11","10","9","8","7","6","5","4"};
initgraph(&gd,&gm,"C:\\TC\\BGI");/*put the directory which contains
egavga.bgi*/
circle(x,y,210);
setcolor(4);
settextstyle(4,0,5);
for(i=0;i<12;i++)
    {
    if(i!=3)
        outtextxy(x+(r-14)*cos(M_PI/6*i)-10,y-(r-14)*sin(M_PI/6*i)-26,n[i]);
    else
        outtextxy(x+(r-14)*cos(M_PI/6*i)-20,y-(r-14)*sin(M_PI/6*i)-26,n[i]);
    }
gettime(&t);
printf("The current time is: %2d:%02d:%02d.%02d",t.ti_hour, t.ti_min,t.ti_sec, t.ti_hund);
while(!kbhit())
    {
    setcolor(5);
    setfillstyle(1,5);
    circle(x,y,10);
    floodfill(x,y,5);
    gettime(&t);
    if(t.ti_min!=m)
        {
        setcolor(0);
        line(x,y,x+(r-60)*cos(thetamin*(M_PI/180)),y-(r-60)*sin(thetamin*(M_PI/180)));
        circle(x+(r-80)*cos(thetamin*(M_PI/180)),y-(r-80)*sin(thetamin*(M_PI/180)),10);
        line(x,y,x+(r-110)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-110)*sin(M_PI/6*h-((m/2)*(M_PI/180))));
        circle(x+(r-130)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-130)*sin(M_PI/6*h-((m/2)*(M_PI/180))),10);
        }
    if(t.ti_hour>12)
        t.ti_hour=t.ti_hour-12;
    if(t.ti_hour<4)
        h=abs(t.ti_hour-3);
    else
        h=15-t.ti_hour;
    m=t.ti_min;
    if(t.ti_min<=15)
        thetamin=(15-t.ti_min)*6;
    else
        thetamin=450-t.ti_min*6;
    if(t.ti_sec<=15)
        thetasec=(15-t.ti_sec)*6;
    else
        thetasec=450-t.ti_sec*6;
    setcolor(4);
    line(x,y,x+(r-110)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-110)*sin(M_PI/6*h-((m/2)*(M_PI/180))));
    circle(x+(r-130)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-130)*sin(M_PI/6*h-((m/2)*(M_PI/180))),10);
    line(x,y,x+(r-60)*cos(thetamin*(M_PI/180)),y-(r-60)*sin(thetamin*(M_PI/180)));
    circle(x+(r-80)*cos(thetamin*(M_PI/180)),y-(r-80)*sin(thetamin*(M_PI/180)),10);
    setcolor(15);
    line(x,y,x+(r-70)*cos(thetasec*(M_PI/180)),y-(r-70)*sin(thetasec*(M_PI/180)));
    delay(1000);
    setcolor(0);
    line(x,y,x+(r-70)*cos(thetasec*(M_PI/180)),y-(r-70)*sin(thetasec*(M_PI/180)));
    }
}

Manual Clock Project

#include<graphics.h>
#include<stdio.h>
void clock(void);
void clock1(void);
void main()
{
int a,x,y,d,m;
d=DETECT;
initgraph(&d,&m,"C:\\TC\\BGI");
cleardevice();
setcolor(4);
outtextxy(100,100,"Press Any Key Repeatedly and See the Trick");
clock();
for(x=303,y=150;x<=353;x=x+5)
    {
    setcolor(4);
    line(303,210,x,y+5);
    getch();
    cleardevice();
    clock();
    }
for(x=353,y=155;x<=403,y<=180;x+=5,y+=3)
    {
    setcolor(4);
    line(303,210,x,y);
    getch();
    cleardevice();
    clock();
    }
for(x=403,y=180;y<=250;y=y+5)
    {
    setcolor(4);
    line(303,210,x,y);
    getch();
    cleardevice();
    clock();
    }
for(x=403,y=250;x>=350,y<=270;x-=5,y+=2)
    {
    setcolor(4);
    line(303,210,x,y);
    getch();
    cleardevice();
    clock();
    }
for(x=350,y=270;x>=250;x-=5)
    {
    setcolor(4);
    line(303,210,x,y);
    getch();
    cleardevice();
    clock();
    }
for(x=250,y=270;x>=200,y>=250;x-=4,y-=2)
    {
    setcolor(4);
    line(303,210,x,y);
    getch();
    cleardevice();
    clock();
    }
for(x=200,y=250;y>=170;y-=4)
    {
    setcolor(4);
    line(303,210,x,y);
    getch();
    cleardevice();
    clock();
    }
for(x=200,y=170;x<=250,y>=150;x+=5,y-=1)
    {
    setcolor(4);
    line(303,210,x,y);
    getch();
    cleardevice();
    clock();
    }
cleardevice();
clock1();
getch();
closegraph();
}

void clock(void)
{
setbkcolor(14);
setcolor(2);
outtextxy(350,150,"1");
outtextxy(250,150,"11");
outtextxy(300,150,"12");

outtextxy(400,170,"2");
outtextxy(400,210,"3");
outtextxy(400,250,"4");

outtextxy(350,270,"5");
outtextxy(300,270,"6");
outtextxy(250,270,"7");

outtextxy(200,250,"8");
outtextxy(200,210,"9");
outtextxy(200,170,"10");

setcolor(1);
line(180,130,420,130);
line(180,290,420,290);
line(180,130,180,290);
line(420,130,420,290);
circle(303,210,7);
setcolor(6);
setlinestyle(0,0,3);
line(303,210,303,250);
setcolor(11);
setlinestyle(0,5,2);
line(303,210,303,155);
}


void clock1(void)
{
setbkcolor(14);
setcolor(2);
outtextxy(350,150,"1");
outtextxy(250,150,"11");
outtextxy(300,150,"12");

outtextxy(400,170,"2");
outtextxy(400,210,"3");
outtextxy(400,250,"4");

outtextxy(350,270,"5");
outtextxy(300,270,"6");
outtextxy(250,270,"7");

outtextxy(200,250,"8");
outtextxy(200,210,"9");
outtextxy(200,170,"10");

setcolor(1);
line(180,130,420,130);
line(180,290,420,290);
line(180,130,180,290);
line(420,130,420,290);
circle(303,210,7);
setcolor(6);
setlinestyle(0,0,3);
line(303,210,303,250);
setcolor(11);
setlinestyle(0,5,2);
line(303,210,313,155);
setcolor(4);
line(303,210,303,155);
getch();
}

Auto clock Project

#include<graphics.h>
#include<stdio.h>
void clock(void);
void clock1(void);
void main()
{
int a,x,y,d,m;
d=DETECT;
initgraph(&d,&m,"C:\\TC\\BGI");
cleardevice();
setcolor(4);
clock();
for(x=303,y=150;x<=353;x=x+10)/*FROM 12 TO 1*/
    {
    setcolor(4);
    line(303,210,x,y+5);
    delay(1000);
    cleardevice();
    clock();
    }
for(x=353,y=155;x<=403,y<=180;x+=10,y+=6)/*FROM 1 TO 2*/
    {
    setcolor(4);
    line(303,210,x,y);
    delay(1000);
    cleardevice();
    clock();
    }
for(x=403,y=180;y<=250;y+=10)/*FROM 2 TO 4*/
    {
    setcolor(4);
    line(303,210,x,y);
    delay(1000);
    cleardevice();
    clock();
    }
for(x=403,y=250;x>=350,y<=270;x-=10,y+=4)/*FROM 4 TO 5*/
    {
    setcolor(4);
    line(303,210,x,y);
    delay(1000);
    cleardevice();
    clock();
    }
for(x=350,y=270;x>=250;x-=10)/*FROM 5 TO 7*/
    {
    setcolor(4);
    line(303,210,x,y);
    delay(1000);
    cleardevice();
    clock();
    }
for(x=250,y=270;x>=200,y>=250;x-=8,y-=4)/*FROM 7 TO 8*/
    {
    setcolor(4);
    line(303,210,x,y);
    delay(1000);
    cleardevice();
    clock();
    }
for(x=200,y=250;y>=170;y-=8)/*FROM 8 TO 10*/
    {
    setcolor(4);
    line(303,210,x,y);
    delay(1000);
    cleardevice();
    clock();
    }
for(x=200,y=170;x<=250,y>=150;x+=10,y-=2)/*FROM 10 TO 11*/
    {
    setcolor(4);
    line(303,210,x,y);
    delay(1000);
    cleardevice();
    clock();
    }
cleardevice();
clock1();
getch();
closegraph();
}

void clock(void)
{
setbkcolor(14);
setcolor(2);
outtextxy(350,150,"1");
outtextxy(250,150,"11");
outtextxy(300,150,"12");

outtextxy(400,170,"2");
outtextxy(400,210,"3");
outtextxy(400,250,"4");

outtextxy(350,270,"5");
outtextxy(300,270,"6");
outtextxy(250,270,"7");

outtextxy(200,250,"8");
outtextxy(200,210,"9");
outtextxy(200,170,"10");

setcolor(1);
line(180,130,420,130);
line(180,290,420,290);
line(180,130,180,290);
line(420,130,420,290);
circle(303,210,7);
setcolor(6);
setlinestyle(0,0,3);
line(303,210,303,250);
setcolor(11);
setlinestyle(0,5,2);
line(303,210,303,155);
}


void clock1(void)
{
setbkcolor(14);
setcolor(2);
outtextxy(350,150,"1");
outtextxy(250,150,"11");
outtextxy(300,150,"12");

outtextxy(400,170,"2");
outtextxy(400,210,"3");
outtextxy(400,250,"4");

outtextxy(350,270,"5");
outtextxy(300,270,"6");
outtextxy(250,270,"7");

outtextxy(200,250,"8");
outtextxy(200,210,"9");
outtextxy(200,170,"10");

setcolor(1);
line(180,130,420,130);
line(180,290,420,290);
line(180,130,180,290);
line(420,130,420,290);
circle(303,210,7);
setcolor(6);
setlinestyle(0,0,3);
line(303,210,303,250);
setcolor(11);
setlinestyle(0,5,2);
line(303,210,313,155);
setcolor(4);
line(303,210,303,155);
getch();
}

DataBase project of class file 3

DataBase project of class file 3
void inputs(int c[],int so[],int ss[],int sss[],int k)
    {
    int i;
    printf("Enter Roll No.=");
        scanf("%d",&c[k]);
    for(i=0;i<k;i++)
        if(c[k]==c[i])
            {
            printf("Roll No. of Two Students cannot be Same.\n");
            printf("Enter Roll No. Again=");
                scanf("%d",&c[k]);
            }   
    printf("Enter MARKS of SUBJECT 1=");
        scanf("%d",&so[k]);
    printf("Enter MARKS of SUBJECT 2=");
        scanf("%d",&ss[k]);
    printf("Enter MARKS of SUBJECT 3=");
        scanf("%d",&sss[k]);
    }


void mao(int m[],int so[],int ss[],int sss[],int k)
    {
    m[k]=so[k]+ss[k]+sss[k];
    }


void age(float p[],int m[],int k)
    {
    p[k]=m[k]/3.0;
    }

   
void gra(int gd[],float p[],int k)
    {
    if(p[k]>=80)
        gd[k]=1;
    else if(p[k]>=70 && p[k]<80)
        gd[k]=2;
    else if(p[k]>=60 && p[k]<70)
        gd[k]=3;
    else if(p[k]>=50 && p[k]<60)
        gd[k]=4;
    else
        gd[k]=5;
    }


double cavg(int m[],int l)
    {
    int i,sum=0;
    double ca;
    for(i=0;i<l;i++)
        sum=sum+m[i];
    ca=sum/l;
    return ca;
    }


void first_last(int m[],int c[],int l)
    {
    int i,max=m[0],max_index=0,min=m[0],min_index=0;
    clrscr();
    for(i=1;i<l;i++)
        {
        if(max<m[i])
            {
            max=m[i];
            max_index=i;
            }
        else if(min>m[i])
            {
            min=m[i];
            min_index=i;
            }
        }
    printf("Roll Number of TOPPER Student is %d",c[max_index]);
    printf("\nRoll Number of NULL Student is %d",c[min_index]);
    }


void sortA_mao(int c[],int so[],int ss[],int sss[],int m[],float p[],int gd[],int e[],int l)
    {
    int i,j,large,l_index;
    for(i=0;i<l-1;i++)
        {
        large=m[i];
        l_index=i;
        for(j=i+1;j<l;j++)
            {
            if(large<m[j])
                {
                large=m[j];
                l_index=j;
                }
            }
        m[l_index]=m[i];
        m[i]=large;
       
       
        e[i]=c[i];
        c[i]=c[l_index];
        c[l_index]=e[i];           
            e[i]=so[i];
            so[i]=so[l_index];
            so[l_index]=e[i];
        e[i]=ss[i];
        ss[i]=ss[l_index];
        ss[l_index]=e[i];
            e[i]=sss[i];
            sss[i]=sss[l_index];
            sss[l_index]=e[i];
        e[i]=p[i];
        p[i]=p[l_index];
        p[l_index]=e[i];
            e[i]=gd[i];
            gd[i]=gd[l_index];
            gd[l_index]=e[i];
        }
    }


void sortD_mao(int c[],int so[],int ss[],int sss[],int m[],float p[],int gd[],int e[],int l)
    {
    int i,j,small,s_index;
    for(i=0;i<l-1;i++)
        {
        small=m[i];
        s_index=i;
        for(j=i+1;j<l;j++)
            {
            if(small>m[j])
                {
                small=m[j];
                s_index=j;
                }
            }
        m[s_index]=m[i];
        m[i]=small;
       
       
        e[i]=c[i];
        c[i]=c[s_index];
        c[s_index]=e[i];           
            e[i]=so[i];
            so[i]=so[s_index];
            so[s_index]=e[i];
        e[i]=ss[i];
        ss[i]=ss[s_index];
        ss[s_index]=e[i];
            e[i]=sss[i];
            sss[i]=sss[s_index];
            sss[s_index]=e[i];
        e[i]=p[i];
        p[i]=p[s_index];
        p[s_index]=e[i];
            e[i]=gd[i];
            gd[i]=gd[s_index];
            gd[s_index]=e[i];
        }
    }


void fetch(int c[],int so[],int ss[],int sss[],int m[],float p[],int gd[],int el,int l)
    {
    int i,a,loc=-1;
    char g;
    clrscr();
    printf("R.No.\tSUB 1\tSUB 2\tSUB 3\tT.MARKS\t%AGE\tGRADE");
    for(i=0;i<l;i++)
        {
        switch(gd[i])
            {
            case 1:
                g='A';
                break;
            case 2:
                g='B';
                break;
            case 3:
                g='C';
                break;
            case 4:
                g='D';
                break;
            case 5:
                g='F';
                break;
            }
        if(el==c[i])
            {
            loc=i;
            break;
            }
        }   
        if(loc==-1)
            printf("\nSORRY! \x1 RECORD OF \"%d\" DOES NOT EXIST.",el);
        else
            {
            printf("\n%d\t%d\t%d\t%d\t%d\t%0.2f\t%c",c[loc],so[loc],ss[loc],sss[loc],m[loc],p[loc],g);
            }
    }


void display(int s[],int c[],int so[],int ss[],int sss[],int m[],float p[],int gd[],int l,double ca)
    {
    int i;
    char g;
    clrscr();
    printf("S.No.\tR.No.\tSUB 1\tSUB 2\tSUB 3\tT.MARKS\t%AGE\tGRADE\n");
    for(i=0;i<l;i++)
        {
        s[i]=i+1;
        switch(gd[i])
            {
            case 1:
                g='A';
                break;
            case 2:
                g='B';
                break;
            case 3:
                g='C';
                break;
            case 4:
                g='D';
                break;
            case 5:
                g='F';
                break;
            }
        printf("%d\t%d\t%d\t%d\t%d\t%d\t%0.2f\t%c\n",s[i],c[i],so[i],ss[i],sss[i],m[i],p[i],g);
        }
    printf("\nCLASS AVERAGE is=%0.2f",ca);
    }


void S_display(int c[],int so[],int ss[],int sss[],int m[],float p[],int gd[],int l,double ca)
    {
    int i;
    char g;
    clrscr();
    printf("R.No.\tSUB 1\tSUB 2\tSUB 3\tT.MARKS\t%AGE\tGRADE\n");
    for(i=0;i<l;i++)
        {
        switch(gd[i])
            {
            case 1:
                g='A';
                break;
            case 2:
                g='B';
                break;
            case 3:
                g='C';
                break;
            case 4:
                g='D';
                break;
            case 5:
                g='F';
                break;
            }
        printf("%d\t%d\t%d\t%d\t%d\t%0.2f\t%c\n",c[i],so[i],ss[i],sss[i],m[i],p[i],g);
        }
    printf("\nCLASS AVERAGE is=%0.2f",ca);
    }

DataBase project of a class file 2

#include<stdio.h>
#include<database.h>
#define s 60
int sn[s],cn[s],s1[s],s2[s],s3[s],mo[s],gr[s],ex[s];
float page[s];
double cav;
void main()
{
int m,j,t,e;
char ch;
clrscr();
printf("Enter NUMBER of Students in the CLASS:");
    scanf("%d",&m);
for(j=0;j<m;j++)
    {
    inputs(cn,s1,s2,s3,j);
        mao(mo,s1,s2,s3,j);
    age(page,mo,j);
        gra(gr,page,j);
    }
cav=cavg(mo,m);
display(sn,cn,s1,s2,s3,mo,page,gr,m,cav);
printf("\n\nDo You Want to See who is TOPPER & who is NULL ?(Y/N)");
    ch=getch();
if(ch=='y' || ch=='Y')
    first_last(mo,cn,m);
else
    printf("\nOK");
printf("\n\nDo You Want to Sort the Table w.r.t T.MARKS ?(Y/N)");
    ch=getch();
if(ch=='y' || ch=='Y')
    {
    printf("\nPress 'a' for ASCENDING ORDER & 'd' for DESCENDING ORDER");
        ch=getch();
    if(ch=='a' || ch=='A')
        {
        sortA_mao(cn,s1,s2,s3,mo,page,gr,ex,m);
        S_display(cn,s1,s2,s3,mo,page,gr,m,cav);
        }
    else
        {
        sortD_mao(cn,s1,s2,s3,mo,page,gr,ex,m);
        S_display(cn,s1,s2,s3,mo,page,gr,m,cav);
        }
    }
else
    printf("\nOK");
printf("\nDo You Want to See the Records of Particular Students ?(Y/N)");
    ch=getch();
if(ch=='y' || ch=='Y')
    {
    clrscr();
    printf("How Many RECORDS You want to See ?");
        scanf("%d",&t);
    for(j=1;j<=t;j++)
        {
        printf("\nEnter Class No. of the Student Whose Record You Want to Fetch:");
        scanf("%d",&e);
        fetch(cn,s1,s2,s3,mo,page,gr,e,m);
        }
    }
else
    printf("\nOK");
getch();
}

DataBase project of class .H file

#include<stdio.h>
#include<database.h>
#include<graphics.h>
#define s 60
int sn[s],cn[s],s1[s],s2[s],s3[s],mo[s],gr[s],ex[s];
float page[s];
double cav;
void main()
{
int m,d,m1,j,t,e;
char ch;
d=DETECT;
initgraph(&d,&m,"C:\\TC\\BGI");
cleardevice();
setcolor(10);
setbkcolor(8);
printf("Enter NUMBER of Students in the CLASS:");
    scanf("%d",&m1);
for(j=0;j<m1;j++)
    {
    inputs(cn,s1,s2,s3,j);
        mao(mo,s1,s2,s3,j);
    age(page,mo,j);
        gra(gr,page,j);
    }
cav=cavg(mo,m1);
display(sn,cn,s1,s2,s3,mo,page,gr,m1,cav);
printf("\n\nDo You Want to See who is TOPPER & who is NULL ?(Y/N)");
    ch=getch();
if(ch=='y' || ch=='Y')
    first_last(mo,cn,m1);
else
    printf("\nOK");
printf("\n\nDo You Want to Sort the Table w.r.t T.MARKS ?(Y/N)");
    ch=getch();
if(ch=='y' || ch=='Y')
    {
    printf("\nPress 'a' for ASCENDING ORDER & 'd' for DESCENDING ORDER");
        ch=getch();
    if(ch=='a' || ch=='A')
        {
        sortA_mao(cn,s1,s2,s3,mo,page,gr,ex,m1);
        S_display(cn,s1,s2,s3,mo,page,gr,m1,cav);
        }
    else
        {
        sortD_mao(cn,s1,s2,s3,mo,page,gr,ex,m1);
        S_display(cn,s1,s2,s3,mo,page,gr,m1,cav);
        }
    }
else
    printf("\nOK");
printf("\nDo You Want to See the Records of Particular Students ?(Y/N)");
    ch=getch();
if(ch=='y' || ch=='Y')
    {
    clrscr();
    printf("How Many RECORDS You want to See ?");
        scanf("%d",&t);
    for(j=1;j<=t;j++)
        {
        printf("\nEnter Class No. of the Student Whose Record You Want to Fetch:");
        scanf("%d",&e);
        fetch(cn,s1,s2,s3,mo,page,gr,e,m1);
        }
    }
else
    printf("\nOK");
getch();
closegraph();
}

Sunday, 20 August 2017

client.java examples of java

package ACP.Patient;

import javax.swing.JOptionPane;
import java.io.*;
//////////////////////////////////////////////////////
class Client
{
    public static void main(String[] fileName)
    {
        final int ARRAY_SIZE    = 50;
        Patient []patient    = new Patient[ARRAY_SIZE];
        int numPatients        = 0;
        String[] choices    = {"", "Add New Patient Record", "Update Patient Information", "Update Prescription & Disease History", "Delete Patient Record", "Search & View Patient Record By Patient ID", "Search & View Patient Record By Patient Name", "Search & View Patient Record By Patient Age", "Search & View Patient Record By Disease category", "Search & View Patient Record By Doctor Name", "Exit"};
        String[] Continue    = {"", "Yes", "No"};
        ObjectOutputStream oOS    = null;
        ObjectInputStream  oIS    = null;
    //////////////////////////////////////////////////////
        String choice        = null;
        String cont        = null;
        int i            = 0;                   
    /////////////////////////////////////////////////////
        if(fileName.length == 0)
        {
            JOptionPane.showMessageDialog(null, "File Name Not Sent From Command Line\nExecute Again With File Name", "Error", JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }
    ////////////////////////////////////////////////////
        try
        {
            Patient temp = null;
            oIS         = new ObjectInputStream(new FileInputStream(fileName[0]));
            for(i = 0; i < ARRAY_SIZE; i++)
            {
                temp = (Patient) oIS.readObject();
                if(temp != null)
                {
                    patient[i] = temp;
                    numPatients++;
                }
            }
            oIS.close();
        }
        catch(ClassNotFoundException cNFE)
        {
            JOptionPane.showMessageDialog(null, "Error\n" + cNFE, "Class Not Found Exception in Reading Objects", JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }
        catch(FileNotFoundException fNFE){}
        catch(EOFException eOFE){}
        catch(IOException iOE)
        {
            JOptionPane.showMessageDialog(null, "Error\n" + iOE, "I/O Exception in Reading Objects", JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, "Error\n" + e, "Exception in Reading Objects", JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }

        Patient.readNextID();
    ///////////////////////////////////////////////////
        do
        {
            choice = (String) JOptionPane.showInputDialog(null, "What You Want To Do ?", "Main Menu", JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
            while(choice.equals(choices[0]))
                choice = (String) JOptionPane.showInputDialog(null, "Field Cannot Be Empty\nWhat You Want To Do ?", "Main Menu", JOptionPane.ERROR_MESSAGE, null, choices, choices[0]);
       
            if(choice.equals(choices[1]))
            {
                if(numPatients < 0 || numPatients >= ARRAY_SIZE)
                    JOptionPane.showMessageDialog(null, "No Space for New patients :(", "Database Full", JOptionPane.WARNING_MESSAGE);
                else
                {
                    patient[numPatients] = new Patient();
                    numPatients++;
                }               
            }
            else if(choice.equals(choices[2]))
            {
                if(numPatients <= 0)
                    JOptionPane.showMessageDialog(null, "No Records Available", "Database Empty", JOptionPane.WARNING_MESSAGE);
                else
                    patient[0].updatePatientInfo(patient, numPatients);
            }   
            else if(choice.equals(choices[3]))
            {
                if(numPatients <= 0)
                    JOptionPane.showMessageDialog(null, "No Records Available", "Database Empty", JOptionPane.WARNING_MESSAGE);
                else
                    patient[0].updatePrescriptionDiseaseHistory(patient, numPatients);
            }
            else if(choice.equals(choices[4]))
            {
                if(numPatients <= 0)
                    JOptionPane.showMessageDialog(null, "No Records Available", "Database Empty", JOptionPane.WARNING_MESSAGE);
                else
                    numPatients = patient[0].deletePatientInfo(patient, numPatients);
            }
            else if(choice.equals(choices[5]))
            {
                if(numPatients <= 0)
                    JOptionPane.showMessageDialog(null, "No Records Available", "Database Empty", JOptionPane.WARNING_MESSAGE);
                else
                    patient[0].searchView_patientID(patient, numPatients);
            }
            else if(choice.equals(choices[6]))
            {
                if(numPatients <= 0)
                    JOptionPane.showMessageDialog(null, "No Records Available", "Database Empty", JOptionPane.WARNING_MESSAGE);
                else
                    patient[0].searchView_patientName(patient, numPatients);
            }
            else if(choice.equals(choices[7]))
            {
                if(numPatients <= 0)
                    JOptionPane.showMessageDialog(null, "No Records Available", "Database Empty", JOptionPane.WARNING_MESSAGE);
                else
                    patient[0].searchView_patientAge(patient, numPatients);
            }
            else if(choice.equals(choices[8]))
            {
                if(numPatients <= 0)
                    JOptionPane.showMessageDialog(null, "No Records Available", "Database Empty", JOptionPane.WARNING_MESSAGE);
                else
                    patient[0].searchView_diseaseCategory(patient, numPatients);
            }
            else if(choice.equals(choices[9]))
            {
                if(numPatients <= 0)
                    JOptionPane.showMessageDialog(null, "No Records Available", "Database Empty", JOptionPane.WARNING_MESSAGE);
                else
                    patient[0].searchView_doctorName(patient, numPatients);
            }
            else if(choice.equals(choices[10]))
            {
                JOptionPane.showMessageDialog(null, "Good Bye", "Exiting", JOptionPane.PLAIN_MESSAGE);
                               
                if(numPatients > 0)
                {
                    try                       
                    {
                        oOS = new ObjectOutputStream(new FileOutputStream(fileName[0]));
                        for(i = 0; i < ARRAY_SIZE; i++)
                            oOS.writeObject(patient[i]);
                        oOS.close();
                    }
                    catch(IOException iOE)
                    {
                        JOptionPane.showMessageDialog(null, "Error\n" + iOE, "I/O Exception in Writing Objects", JOptionPane.ERROR_MESSAGE);
                    }
                    catch(Exception e)
                    {
                        JOptionPane.showMessageDialog(null, "Error\n" + e, "Exception in Writing Objects", JOptionPane.ERROR_MESSAGE);
                    }

                    Patient.writeNextID();
                }
                System.exit(0);
            }
            cont = (String) JOptionPane.showInputDialog(null, "Want to go back to Main Menu ?", "Continue or Exit", JOptionPane.QUESTION_MESSAGE, null, Continue, Continue[0]);
            while(cont.equals(Continue[0]))
                cont = (String) JOptionPane.showInputDialog(null, "Field Cannot Be Empty\nWant to go back to Main Menu ?", "Continue or Exit", JOptionPane.ERROR_MESSAGE, null, Continue, Continue[0]);
        }
        while(cont.equals(Continue[1]));
    ///////////////////////////////////////////////////
        JOptionPane.showMessageDialog(null, "Good Bye", "Exiting", JOptionPane.PLAIN_MESSAGE);
       
        if(numPatients > 0)
        {
            try                       
            {
                oOS = new ObjectOutputStream(new FileOutputStream(fileName[0]));
                for(i = 0; i < ARRAY_SIZE; i++)
                    oOS.writeObject(patient[i]);
                oOS.close();
            }
            catch(IOException iOE)
            {
                JOptionPane.showMessageDialog(null, "Error\n" + iOE, "I/O Exception in Writing Objects", JOptionPane.ERROR_MESSAGE);
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(null, "Error\n" + e, "Exception in Writing Objects", JOptionPane.ERROR_MESSAGE);
            }
        }

        Patient.writeNextID();
    ///////////////////////////////////////////////////
    }
}

java example questions




Build a program which should have two classes Patient and Client. Both of the classes should be in package ACP.Patient .Patient class should have following data members and Functionalities

Data members:
Patient Name

Father name
Date of birth (Date)
Patient ID (Number)
Disease Category (Heart, ENT, Diabetic, Brain, Orthopedic, General)
NIC (String)
Doctor Name
Prescription
Disease History

Functionalities:
setPatientInformation
updatePrescriptionDiseaseHistory
updatePatientInfo
deletePatientInfo
Search and View Patient record by
Patient ID
Patient Name
Patient Age
Disease Category
Doctor Name
Client class should have main function where it may have capacity of maximum 50 Patient records.
User should be given choice whether to
Add New Patient record
Update Prescription & Disease History
Update Patient Information
Delete Patient Record
Search & view Patient
            BY Patient ID
            By Patient Name
            By Age
            By Disease Category
            By Doctor Name
Choices may be taken by using Input Message dialogs.