Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that computes a patient\'s bill for a hospital stay. the differe

ID: 3841915 • Letter: W

Question

Write a program that computes a patient's bill for a hospital stay. the different components of the program are: The Patient Account class the Surgery class the Pharmacy class the main program the Patient Account class will keep a total of the patient's charges. It will also keep track of the number of days spent in the hospital. ($500 per day) the Surgery class will have stored within it the charges for at least five types of surgery (Sl:$100. S2.S200, S3:$300, S4:$400, S5:$500). It can update the charges variable of the Patient Account class. the Pharmacy class will have stored within it the price of at least five types of medication (Ml: $10, M2: $20, M3: $30, M4: $40, M5: $50). It can update the charges variable of the Patient Account class. the main program has a menu that allows the user to enter a type of surgery, a type of medication, number of days of hospital stay, and check the patient out of the hospital. When the patient checks out, the total charges should be displayed.

Explanation / Answer

// PatientAccount class

public class PatientAccount {

private int daysSpent;

private final int chargePerDay = 500;

private static int totalCharge;

public int getDaysSpent() {

return daysSpent;

}

public void setDaysSpent(int daysSpent) {

this.daysSpent = daysSpent;

totalCharge += this.daysSpent * chargePerDay;

}

  

public static void updateAccount(int money){

totalCharge += money;

}

  

public static int getFinalAmount(){

return totalCharge;

}

}

// surgery class

public class Surgery {

public final static int S1 = 100;

public final static int S2 = 200;

public final static int S3 = 300;

public final static int S4 = 400;

public final static int S5 = 500;

public void updatePatientAccount(int charge){

PatientAccount.updateAccount(charge);

}

}

// Pharmacy class

public class Pharmacy {

public final static int M1 = 10;

public final static int M2 = 20;

public final static int M3 = 30;

public final static int M4 = 40;

public final static int M5 = 50;

public void updatePatientAccount(int charge) {

PatientAccount.updateAccount(charge);

}

}

// main class

public class Main {

public static void main(String[] args) {

while (true) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter Type of surgery [S1 - S5] : ");

String str = sc.next();

Surgery surgery = new Surgery();

if (str.equalsIgnoreCase("S1")) {

surgery.updatePatientAccount(Surgery.S1);

} else if (str.equalsIgnoreCase("S2")) {

surgery.updatePatientAccount(Surgery.S2);

} else if (str.equalsIgnoreCase("S3")) {

surgery.updatePatientAccount(Surgery.S3);

} else if (str.equalsIgnoreCase("S4")) {

surgery.updatePatientAccount(Surgery.S4);

} else if (str.equalsIgnoreCase("S5")) {

surgery.updatePatientAccount(Surgery.S5);

}

System.out.print("Enter Type of Medication [M1 - M5]: ");

String medication = sc.next();

Pharmacy pharmacy = new Pharmacy();

if (medication.equalsIgnoreCase("M1")) {

pharmacy.updatePatientAccount(Pharmacy.M1);

} else if (medication.equalsIgnoreCase("M2")) {

pharmacy.updatePatientAccount(Pharmacy.M2);

} else if (medication.equalsIgnoreCase("M3")) {

pharmacy.updatePatientAccount(Pharmacy.M3);

} else if (medication.equalsIgnoreCase("M4")) {

pharmacy.updatePatientAccount(Pharmacy.M4);

} else if (medication.equalsIgnoreCase("M5")) {

pharmacy.updatePatientAccount(Pharmacy.M5);

}

System.out.print("No. Of days of hospital stay : ");

int days = sc.nextInt();

PatientAccount account = new PatientAccount();

account.setDaysSpent(days);

System.out.print("Do you want to checkout?? Y/n : ");

String choice = sc.next();

if (choice.trim().equalsIgnoreCase("y")) {

System.out.println("TOTAL AMOUNT : " + PatientAccount.getFinalAmount());

System.exit(0);

}

}

}

}

Program will ask surgery type first then it will ask meditation type and then it will ask number of hospital stay. after that if program ask if you want to checkout or want to do surgery,meditation again. if you choose to checkout then program will display final total amount on the screen.

Hope you understand. if you still have any doubt feel free to ask in comment.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote