Professional Documents
Culture Documents
for (i=0;i<5;i++)
{ System.out.println("Enter the Admission Number of Patient "+(i+1));
admno[i]=Integer.parseInt(br.readLine());
System.out.println("Enter the Date of Admission of Patient "+(i+1)+ " in Format DD/MM/YY");
admdate[i]=br.readLine();
System.out.println("Enter the Name of Patient "+(i+1));
name[i]=br.readLine();
System.out.println("Enter the Age of Patient "+(i+1));
age[i]=Integer.parseInt(br.readLine());
System.out.println("Enter the Gender of Patient "+(i+1)+" as M or F ");
g[i]=br.readLine().charAt(0);System.out.println();
}// end of for loop
System.out.println("Menu:\n 1. Display the list of Male Patients");
System.out.println(" 2. Display the list of Patients Admitted on a Specific Date");
System.out.println(" 3. Display the list of patients in Ascending Order of their Age");
System.out.println(" 4. To Enter a New Entry");
System.out.println(" 5. Delete an existing Entry\n 6. Exit");
do{
System.out.println("Enter choice");
choice=Integer.parseInt(br.readLine());
flag=0;
switch (choice)
{ case 1:
for (i=0;i<10;i++)//displaying the list of male patients
{ if(g[i]=='M')
flag++;
if(flag==1 && g[i]=='M')
System.out.println("Admission No.\tAdmission Date\tName\t\tAge\tGender");
if(g[i]=='M')
System.out.println(admno[i]+"\t\t "+admdate[i]+"\t"+name[i]+"\t "+age[i]+"\t "+g[i]+"\t");
}//end of for loop
if(flag==0)
System.out.println("No Male Patients admitted in the Nursing Home"); break;
case 3:
for(i=0;i<9;i++)//Sorting the data in ascending order of age through Bubble Sort
{ for(j=0;j<9-i;j++)
{ if (age[j] > age[j+1])
{ temp_int=age[j];age[j]=age[j+1];age[j+1]=temp_int;
temp_int=admno[j];admno[j]=admno[j+1];admno[j+1]=temp_int;
temp_str=admdate[j];admdate[j]=admdate[j+1];admdate[j+1]=temp_str;
temp_str=name[j];name[j]=name[j+1];name[j+1]=temp_str;
temp_char=g[j];g[j]=g[j+1];g[j+1]=temp_char;
}//end of if
}//end of inner for loop
}//end of outer for loop
System.out.println("List of Patients in Ascending order of Age ");
System.out.println("Admission No.\tAdmission Date\tName\t\tAge\tGender");
for (i=0;i<10;i++)
{ if(age[i]>0)
System.out.println(admno[i]+"\t\t "+admdate[i]+"\t"+name[i]+"\t "+age[i]+"\t "+g[i]+"\t");
}//end of for loop
break;
case 4:
for(i=0;i<10;i++)//entering a new entry
{ if(admno[i]==0)
{ System.out.println("Enter the Admission Number of the Patient");
admno[i]=Integer.parseInt(br.readLine());
System.out.println("Enter the Date of Admission in format DD/MM/YY");
admdate[i]=br.readLine();
System.out.println("Enter the Name of the Patient");
name[i]=br.readLine();
System.out.println("Enter the Age of the Patient");
age[i]=Integer.parseInt(br.readLine());
System.out.println("Enter the Gender of the Patient as M or F");
g[i]=br.readLine().charAt(0);
flag=1;break;
}//end of if
}//end of for loop
if(flag==0)
System.out.println("There are no vacancies in the Nursing Home"); break;
case 6:
System.out.println("Exiting");break;
default:System.out.println("Wrong Choice");
}//end of switch
}while(choice!= 6); //end of do while loop
}//end of main
}//end of class