Please make a Java program that has a menu method and includes dialog boxes. The program will call the proper method, but each method will be completed later. Your program will keep track of information for a Hospital. The program will be menu-driven. Your menu is to look something like the following:
UPMC Medical Center
Please Make your selection >
In this first phase, you are to write the complete method for the menu and stubs for all of the other methods.
The names and definitions of the methods are as follows:
All of the following must be done in the main method (in this order): This is the pseudo-code to follow post-directions
6. Begin the loop
7. If the selection is equal to 1 write the Java statement to:
call the method Modify_patient
8. If the selection is equal to 2 write the Java statement to:
call the method Modify_physician
9. If the selection is equal to 3 write the Java statement to:
call the method Modify_medical
10. If the selection is equal to 4 write the Java statement to:
call the method Report_section
10. Write the Java statement to Call the method Main_menu and pass back the user’s selection
11. End the while loop
12. Write the Java statement to call the method Exit_upmc
import java.util.*;
public class Main{
static List<String> patientName=new ArrayList<String>();
static List<String> physicianName=new ArrayList<String>();
static List<String> medicalName=new ArrayList<String>();
static Scanner sc=new Scanner(System.in);
public static int Main_Menu(){
System.out.println("UPMC Medical Center");
System.out.println("1.Add/Modify Patient Information");
System.out.println("2.Add/Modify Physician Information");
System.out.println("3.Add/Modify Medical Information");
System.out.println("4.Hospital Report Section");
System.out.println("5.Exit the Medical System");
System.out.print("Please Make your selection >");
int n=sc.nextInt();
return n;
}
public static void read_patient(String name){
patientName.add(name);
}
public static void read_doctor(String name){
physicianName.add(name);
}
public static void read_medical(String name){
medicalName.add(name);
}
public static void Modify_patient(String fname,String tname){
int index=patientName.indexOf(fname);
patientName.remove(fname);
patientName.add(index,tname);
}
public static void Modify_doctor(String fname, String tname){
int index=physicianName.indexOf(fname);
physicianName.remove(fname);
physicianName.add(index,tname);
}
public static void Modify_medical(String fname, String tname){
int index=medicalName.indexOf(fname);
medicalName.remove(fname);
medicalName.add(index,tname);
}
public static void Report_section(){
System.out.println("Patient's list:"+patientName);
System.out.println("Doctor's list:"+physicianName);
System.out.println("Medical list:"+medicalName);
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Enter the Patient name:");
String patName=sc.nextLine();
read_patient(patName);
System.out.print("Enter the Physician name:");
String phName=sc.nextLine();
read_doctor(phName);
System.out.print("Enter the Medical name:");
String mName=sc.nextLine();
read_medical(mName);
int ch;
while(true){
int n=Main_Menu();
if(n==1){
System.out.println("1.Add Patient name\n2.Modify Patient name");
System.out.print("Enter your choice:");
ch=sc.nextInt();
sc.nextLine();
if(ch==1){
System.out.print("Enter the Patient name:");
String pt1=sc.nextLine();
read_patient(pt1);
}
else if(ch==2){
System.out.print("Enter the Patient name of which you want to modify:");
String pt2=sc.nextLine();
System.out.print("Enter the new Patient name to whom you modify to:");
String pt3=sc.nextLine();
Modify_patient(pt2,pt3);
}
}
else if(n==2){
System.out.println("1.Add physician name name\n2.Modify physician name");
System.out.print("Enter your choice:");
ch=sc.nextInt();
sc.nextLine();
if(ch==1){
System.out.print("Enter the physician name:");
String ph1=sc.nextLine();
read_doctor(ph1);
}
else if(ch==2){
System.out.print("Enter the physician name of which you want to modify:");
String ph2=sc.nextLine();
System.out.print("Enter the physician name to whom you modify to:");
String ph3=sc.nextLine();
Modify_doctor(ph2,ph3);
}
}
else if(n==3){
System.out.println("1.Add medical name\n2.Modify medical name");
System.out.print("Enter your choice:");
ch=sc.nextInt();
sc.nextLine();
if(ch==1){
System.out.print("Enter the medical name:");
String m1=sc.nextLine();
read_medical(m1);
}
else if(ch==2){
System.out.print("Enter the medical name of which you want to modify:");
String m2=sc.nextLine();
System.out.print("Enter the medical name to whom you modify to:");
String m3=sc.nextLine();
Modify_medical(m2,m3);
}
}
else if(n==4){
Report_section();
}
else if(n==5){
break;
}
else{
System.out.println("Invalid Input");
}
}
}
}
Screenshots of the code for reference:
OUTPUT :
Thank you! if you have any queries post it below in the comment section I will try my best to resolve your queries and I will add it to my answer if required.
If you want to add any code comment it
below. Please give upvote if you like my
work.
Get Answers For Free
Most questions answered within 1 hours.