import javax.swing.JOptionPane;
public class hospital_copy {
public static void main(String[] args) {
//Declare variables
String patient_last, surgery_location, surgery_type, insurance_fee, surgeon_name, output="";
double agh_count=0, upmc_count=0;
double fee = 0, agh_fee = 0, upmc_fee = 0, high_fee = 0;
int count_knee=0, count_hip=0;
String highest_surgeon="";
String high_patient="";
String high_surgeon="";
String high_location="";
String more_data = "yes";
int Atkins_count=0,Johnson_count=0,Smith_count=0;
while(more_data.equals("yes"))
{
//Read the data
patient_last=JOptionPane.showInputDialog(null,"Enter Patient's Last Name",
"Input Data", JOptionPane.QUESTION_MESSAGE);
surgery_location=JOptionPane.showInputDialog(null,"Enter the Surgery Location (AGH or UPMC)",
"Input Data", JOptionPane.QUESTION_MESSAGE);
surgery_type=JOptionPane.showInputDialog(null,"Enter the Type of Surgery (knee or hip)",
"Input Data", JOptionPane.QUESTION_MESSAGE);
insurance_fee=JOptionPane.showInputDialog(null,"Enter the Amount of Fee Paid By Insurance",
"Input Data", JOptionPane.QUESTION_MESSAGE);
//parse insurance fee to double
fee=Double.parseDouble(insurance_fee);
surgeon_name=JOptionPane.showInputDialog(null,"Enter the Surgeon's Name (Johnson, Atkins, or Smith)",
"Input Data", JOptionPane.QUESTION_MESSAGE);
//Count number of each type of surgery
if(surgery_type.equals("knee"))
count_knee=count_knee+1;
else
count_hip=count_hip+1;
//Count number of surgeries at each location
if(surgery_location.equals("UPMC"))
{
upmc_count=upmc_count+1;
upmc_fee=upmc_fee+fee;
}
if(surgery_location.equals("AGH"))
{
agh_count=agh_count+1;
agh_fee=agh_fee+fee;
}
//Count number of surgeries each surgeon did
if(surgeon_name.equals("Johnson"))
Johnson_count=Johnson_count+1;
else
if(surgeon_name.equals("Atkins"))
Atkins_count=Atkins_count+1;
else
Smith_count=Smith_count+1;
//Find surgeon with highest fee
if (fee>high_fee)
{
high_fee=fee;
high_patient=patient_last;
high_surgeon=surgeon_name;
high_location=surgery_location;
}
//Ask if more data
more_data=JOptionPane.showInputDialog(null,"More Info? Enter yes or no",
"Input Dialog",JOptionPane.QUESTION_MESSAGE);
}//End of while loop
//Calculate average fee for each location
//Find surgeon with most surgeries
if ((Johnson_count > Atkins_count)&(Johnson_count > Smith_count))
highest_surgeon = "Johnson";
else
if ((Atkins_count > Johnson_count)&(Atkins_count > Smith_count))
highest_surgeon = "Atkins";
else
highest_surgeon = "Smith";
//Output data
output=output+"Number of Knee Surgeries: "+count_knee+"\n";
output=output+"Number of Hip Surgeries: "+count_hip+"\n"+"\n";
output=output+"Number of Surgeries Performed by Johnson: "+Johnson_count+"\n";
output=output+"Number of Surgeries Performed by Atkins: "+Atkins_count+"\n";
output=output+"Number of Surgeries Performed by Smith: "+Smith_count+"\n"+"\n";
output=output+"Doctor Who Performed the Most Surgeries: "+highest_surgeon+"\n"+"\n";
output=output+"Patient Whose Insurance Paid Highest Fee: "+high_patient+"\n";
output=output+"Doctor For Above Patient: "+high_surgeon+"\n";
output=output+"Location of Above Patient's Surgery: "+high_location+"\n";
//Display the output dialog box
JOptionPane.showMessageDialog(null,output,"Output",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}//end class
public static void calc_average(double avagh, double avUPMC){
System.out.println(avUPMC);
}
public static double calc_averages(double agh_fee,int agh_count){
double avagh = agh_fee / agh_count;
return avagh;
}
public static double calc_average(double UPMC_fee, int UPMC_count){
double avUPMC = UPMC_fee / UPMC_count;
return avUPMC;
}
} //end method