Question

Please make a Java program that has a menu method and includes dialog boxes. The program...

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

  1. Add/Modify Patient Information
  2. Add/Modify Physician Information
  3. Add/Modify Medical Information
  4. Hospital Report Section
  5. Exit the Medical System

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:

  1. Main_MenuThis method is NOT a stub…This method will print the above menu and will return the user’s selection to the main method. (You will have a while loop in the main JAVA method that calls the menu method until the user selects #5)

All of the following must be done in the main method (in this order): This is the pseudo-code to follow post-directions

  1. Write the java statement to call the method read_patient
  2. Write the java statement to call the method read_doctor
  3. Write the java statement to call the method read_medical
  4. Write the java statement to call the method Main_menu and pass back the user’s selection
  5. Write a While loop that will run until (the selection is not equal to 5)

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

Homework Answers

Answer #1
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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Problem Statement: Write a Java program “HW6_lastname.java” that prints a program title and a menu with...
Problem Statement: Write a Java program “HW6_lastname.java” that prints a program title and a menu with four items. The user should then be prompted to make a selection from the menu and based on their selection the program will perform the selected procedure. The title and menu should be as the following: Student name: <your name should be printed> CIS 232 Introduction to Programming Programming Project 6 Due Date: October 23, 2020 Instructor: Dr. Lomako ******************************** 1.     Compute Angles                               *...
Write a Java program called Decision that includes a while loop to prompt the user to...
Write a Java program called Decision that includes a while loop to prompt the user to enter 5 marks using the JOptionPane statement and a System. Out statement to output a message inside the loop highlighting a pass mark >= 50 and <= 100. Any other mark will output a messaging stating it’s a fail. Example of the expected output is as follows:
This is a Java program Program Description You work for a local cell phone company and...
This is a Java program Program Description You work for a local cell phone company and have been asked to write a program to calculate the price of a cell phone data plan being purchased by a customer. The program should do the following tasks: Display a menu of the data plans that are available to be purchased. Read in the user’s selection from the menu.  Input Validation: If the user enters an invalid option, the program should display an error...
Write a program in Java that: 1. will prompt user with a menu that contains options...
Write a program in Java that: 1. will prompt user with a menu that contains options to: a. Add a To-Do Item to a todo list. A To-Do Item contains: i. An arbitrary reference number (4; 44,004; etc.) ii. A text description of the item ("Pick up dry cleaning", etc.) iii. A priority level (1, 2, 3, 4, or 5) b. View an item in the list (based on its reference number) c. Delete an item from the list (based...
IN JAVA Complete the following program. Add codes in the main method to:1) call method average(double[]...
IN JAVA Complete the following program. Add codes in the main method to:1) call method average(double[] gpaarr ) to calculate the average of gpaArray; 2) add codes in the for loop to calculate sum 3) print the average . public class Test { public static void main (String args[]) { double[ ] gpaArray = { 2.5, 4.0, 3.8, 3.2, 2.9, 4.0 } ;   //add your codes here (you can put your codes in the Answer area with/without copying the original...
complete a C++ program that asks the user to make a choice off a menu that...
complete a C++ program that asks the user to make a choice off a menu that will be displayed to them. The user can make as many selections as they wish. The last choice from the menu will give them an option to stop. The menu choices will be the following four calculations: Find the volume of a cone Find the volume of a sphere Find the area of octagon Find the distance between two points Stop For the different...
Write a C program Design a program that uses an array to store 10 randomly generated...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
Please write it in c# program please and if possible no arrays only loops Loop Introduction...
Please write it in c# program please and if possible no arrays only loops Loop Introduction Assignment Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches.   Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you start doing anything… This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT