Professional Documents
Culture Documents
import java.util.Scanner;
class hsptl{
//patient infos.
int age;
//hospital bills
double[] price = {
200,
1200,
2500,
10000,
3000,
4000,
3500,
2000
};
int n,num,pwd=0;
int a = 0;
double dc = .2;
String[] rooms = {
"Ward",
"Private Room",
"Executive/Suit Room",
"ICU",
"NICU",
"PCIU",
"Incubator Cost"
};
int room = 0;
System.out.println("--------------------------------");
System.out.println("*** H O S P I T A L B I L L ***");
System.out.println("--------------------------------");
do{
//the user will enter the number of patients to be inputted to the program
num = scan.nextInt();
System.out.println("--------------------------------");
hsptl[] ptnt = new hsptl[num];
//this loop is used for entering the patients info, this will repeat until it meets the number of
loops entered(number of patient)
ptnt[i].Fname = scan.next();
ptnt[i].Lname = scan.next();
System.out.print("Age : ");
ptnt[i].age = scan.nextInt();
System.out.print("Sex : ");
ptnt[i].sex = scan.next();
System.out.print("Address : ");
ptnt[i].add = scan.next();
System.out.println("P.W.D.?");
System.out.print("Enter : ");
pwd = scan.nextInt();
if(pwd > 2)
break;
System.out.print("Enter : ");
room = scan.nextInt();
if(room >= 8)
break;
//the user will enter how many days the patient stayed in the room
System.out.print("Days : ");
ptnt[i].med = scan.nextInt();
//solving for subtotal bill by multiplying the room fee and days of stays
if (room == 1)
ptnt[i].bill = ptnt[i].price[0]*day;
System.out.println("Subtotal : " + ptnt[i].bill );
else if (room == 2)
ptnt[i].bill = ptnt[i].price[1]*day;
else if (room == 3)
ptnt[i].bill = ptnt[i].price[2]*day;
else if (room == 4)
ptnt[i].bill = ptnt[i].price[3]*day;
else if (room == 5)
ptnt[i].bill = ptnt[i].price[4]*day;
else if (room == 6)
ptnt[i].bill = ptnt[i].price[5]*day;
System.out.println("Subtotal : " + ptnt[i].bill );
else if (room == 7)
ptnt[i].bill = ptnt[i].price[6]*day;
else if (room == 8)
ptnt[i].bill = ptnt[i].price[7]*day;
else
break;
if (pwd == 1)
else if(pwd == 2)
{
else
break;
else
if (pwd == 1)
else if(pwd == 2)
System.out.println("Discount : No Discount");
else
{
break;
System.out.println("");
/*this loop will display all entered informations of the patient including their hospital bills*/
if(room >= 8)
break;
if(pwd > 2)
break;
System.out.print("Discount : No Discount\t");
do{
if(pwd > 2)
break;
if(room > 8)
break;
}
//it is use to locate or find the informations of patients by entering the patients number
System.out.println("\n***LOCATE PATIENT***");
System.out.print("Enter : ");
a = scan.nextInt();
if (a > 2)
break;
if (a == 1)
System.out.print("\nPatient # : ");
int p = scan.nextInt();
if (p > ptnt.length)
System.out.println("\n!!!Invalid Keyword!!!");
System.out.println("!!!Out Of Range!!!");
continue;
System.out.println("--------------------------------");
System.out.println("Discount : No Discount");
System.out.println("--------------------------------");
}while(a != 2);
//if the user entered higher number than the rooms available in the program, the program will
close automatically
if(pwd > 2)
{
System.out.println("\n!!!Invalid Keyword!!!");
System.out.println("!!!Out Of Range!!!");
break;
if(room > 8)
System.out.println("\n!!!Invalid Keyword!!!");
System.out.println("!!!Out Of Range!!!");
break;
//if the user entered higher number than the stored patient infos, the program will close
automatically
if( a > 2)
System.out.println("\n!!!Invalid Keyword!!!");
System.out.println("!!!Out Of Range!!!");
break;
System.out.println("1. Restart");
System.out.println("2. Exit");
System.out.print("Enter : ");
n = scan.nextInt();
//if the user eneters 3 or higher, the program will close because it only has two choices
if (n > 2)
{
System.out.println("\n!!!Invalid Keyword!!!");
System.out.println("!!!Out Of Range!!!");
break;
System.out.println("--------------------------------");
}while(n != 2);