Date: 05-03-2026
Roll No. and Name: 24BCE179 DEEP HIRPARA
Course Code and Name: JAVA PROGRAMMING
Practical No: 6
Aim:
import [Link].*;
class Patient{
int age;
String name;
String address;
Patient(){
age=0;
name="";
address="";
}
Patient(int age,String name,String address){
[Link]=age;
[Link]=name;
[Link]=address;
}
void display(){
[Link]("Name of patient:"+name);
[Link]("Age:"+age);
[Link]("Address:"+address);
}
}
class CovidParameters extends Patient{
Scanner sc=new Scanner([Link]);
float CTScore;
float Ddimer;
int platelet;
CovidParameters(){
super();
CTScore=0.0f;
Ddimer=0.0f;
platelet=0;
}
CovidParameters(float CTScore,float Ddimer,int platelet,int age,String
name,String address){
super(age,name,address);
[Link]=CTScore;
[Link]=Ddimer;
[Link]=platelet;
}
void Getter(){
[Link]("Enter the Patient's Name:");
name=[Link]();
[Link]("Enter the Patient's Age:");
age=[Link]();
[Link]();
[Link]("Enter the Patient's Address:");
address=[Link]();
[Link]("Enter the CT Score:");
CTScore=[Link]();
[Link]("Enter the D-Dimer:");
Ddimer=[Link]();
[Link]("Enter the Platelet Count:");
platelet=[Link]();
}
void display(){
[Link]();
[Link]("CT Score:"+CTScore);
[Link]("D-Dimer:"+Ddimer);
[Link]("Platelet Count:"+platelet);
}
}
public class Java6a{
public static void main(String[] args) {
Scanner sc=new Scanner([Link]);
CovidParameters[] hospitalWard=null;
int choice = 0;
[Link]("Welcome to the Hospital Management System");
while (choice != 5) {
[Link]("1. Set the Size of an Ward");
[Link]("2. Enter details for all Patients");
[Link]("3. Display all Patients");
[Link]("4. Display Patients sorted by highest CT Score");
[Link]("5. Exit");
[Link]("Enter your choice: ");
choice = [Link]();
switch(choice){
case 1:
[Link]("How many patients will be there? :");
int size = [Link]();
hospitalWard = new CovidParameters[size];
[Link]("Created !");
break;
case 2:
if (hospitalWard == null) {
[Link]("Please create the array first (Option 1).");
} else {
for (int i=0;i<[Link];i++) {
[Link]("\nEntering details for Patient " + (i + 1) + ":");
hospitalWard[i] = new CovidParameters();
hospitalWard[i].Getter();
}
}
break;
case 3:
if(hospitalWard == null || hospitalWard[0]==null) {
[Link]("No patients to display.");
}
else
{
for (int i = 0; i < [Link]; i++) {
[Link]("\n::: Patient " + (i + 1) + "::: ");
hospitalWard[i].display();
[Link]("---:::---:::---:::---:::---:::---:::---:::---:::---:::---:::---:::---:::---:::---");
}
}
break;
case 4:
if (hospitalWard == null || hospitalWard[0] == null) {
[Link]("No patients to sort.");
} else {
for (int i = 0; i < [Link] - 1; i++) {
for (int j = 0; j < [Link] - i - 1; j++) {
if (hospitalWard[j].CTScore < hospitalWard[j + 1].CTScore) {
CovidParameters temp = hospitalWard[j];
hospitalWard[j] = hospitalWard[j + 1];
hospitalWard[j + 1] = temp;
}
}
}
[Link]("\n Patients Sorted by Highest CT Score :::");
for (int i = 0; i < [Link]; i++) {
hospitalWard[i].display();
[Link]("---:::---:::---:::---:::---:::---:::---:::---:::---:::---:::---:::---:::---:::---");
}
}
break;
case 5:
[Link]("Exiting the program. Goodbye!");
break;
default:
[Link]("Invalid choice. Please try again.");
}
}
[Link]();
}
}