Question
Using your code from assignment #1 you are to add a user defined class to your code . All methods and all data are to
Using your code from assignment #1 you are to add a user defined class to your code. All methods and all data are to be part of this new class.
Copy your code to a new Word document along with a screenshot of each report running and upload to Blackboard.
EXISTING CODE:
package doctor_project;
import javax.swing.JOptionPane; import java.io.*; import java.util.*; public class doctor_project { static int[] pnumber=new int[100]; static String[] patname=new String[100]; static String[] docname=new String[100]; static String[] surgery=new String[100]; static double[] cost=new double[100]; static int count=-1; static Scanner stdin = new Scanner(System.in); public static void main(String[] args) throws FileNotFoundException { int selection; start_program(); selection=menu(); while (selection !=6) { if(selection ==1) print_all(); else if (selection ==2) print_doctor_surgery(); else if(selection ==3) print_surgery_specific_type(); else if(selection ==4) print_all_fees(); else if(selection==5) new_report(); selection=menu(); }//end of while loop }//end of main method //****************************************************************************** public static void start_program() throws FileNotFoundException { File inFile = new File("surgery.txt"); Scanner s = new Scanner(inFile); while(s.hasNext()){ count++; String line = s.nextLine(); line = line.substring(0,line.length()-1); String[] words = line.split("#"); pnumber[count] = Integer.parseInt(words[0]); patname[count] = words[1]; docname[count] = words[2]; surgery[count] = words[3]; cost[count] = Double.parseDouble(words[4]); } s.close(); }//end start_program //******************************************************************************
public static int menu() { int selection; String value; String output="HOSPITAL REPORT MENU"+" "+ "=================="+" "+ "1. Print all information"+" "+ "2. All surgeries for a specific Dcotor"+" "+ "3. All surgeries of a specific type"+" "+ "4. Fees Paid to each Doctor"+" "+ "5. Report of your choice"+" "+ "6. Exit"+" "+ "Enter your slection > "; value = JOptionPane.showInputDialog(null, output,"Input Data",JOptionPane.QUESTION_MESSAGE); selection =Integer.parseInt(value); return selection; }//end menu //******************************************************************************
public static void print_doctor_surgery() { String doctor = JOptionPane.showInputDialog(null,"Enter doctor name: ","Input Data",JOptionPane.QUESTION_MESSAGE); boolean found = false; int k = 0; for(int i = 0;i
public static void print_all() { System.out.println("Surgery List: "); System.out.println("=============================================================="); System.out.println(String.format("%10s%30s%15s%20s%10s", "Number","Patient Name","Doctor","Surgery Type","Cost")); System.out.println("=============================================================="); for(int i = 0;i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started