Question

Must be in Java.

Please show step by step process with proper explanation and comments.

Please maintain proper indentation.

You are asked to create the starting point of a system to represent several types of medical doctors. You decided to implemen

Output John, phone: 123-4567, email: john@docs.com Hospital doctor: Jack, staff # 4930, pager: 987-6784 Input John 123-4567 j

CODE PROVIDED:

Doctor.java

HospitalDoctor.java

Q1Runner.java

import java.util.Scanner;

public class Q1Runner {
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
      
       // Do your work here
      
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Doctor.java :

//Java class
public class Doctor {
   //String variables
   private String Name;
   private String Phone;
   private String Email;
   //constructor
   public Doctor(String name,String phone,String email)
   {
       this.Name=name;//set name
       this.Phone=phone;//set name
       this.Email=email;//set email      
   }
   //toString() method
   public String toString()
   {
       //return name , phone and email
       return this.Name+",phone:"+this.Phone+",email:"+this.Email;
   }

}
**************************

HospitalDoctor.java :

//Java class
public class HospitalDoctor extends Doctor {
   //String variables
   private String StaffNumber;
   private String PageNumber;
   //constructor
   public HospitalDoctor(String name,String phone,String email,String staffNumber,String pageNumber)
   {
       //calling base class constructor
       super(name,phone,email);
       this.StaffNumber=staffNumber;//set staff number
       this.PageNumber=pageNumber;//set page number  
      
   }
   //toString() method
   public String toString()
   {
       //return details
       return super.toString()+"\n Hospital doctor :staff #"+this.StaffNumber+",pager:"+this.PageNumber;
   }

}
********************************

Q1Runner.java :

import java.util.Scanner;//import package
//java class

public class Q1Runner {
   // main method, entry point of the class
   public static void main(String[] args) {
//object of Scanner class
       Scanner kb = new Scanner(System.in);
       // asking user name
       System.out.print("Enter Name :");
       String name = kb.nextLine();// reading name
       // asking user phone
       System.out.print("Enter Phone :");
       String phone = kb.nextLine();// reading phone
       // asking user email
       System.out.print("Enter Email :");
       String email = kb.nextLine();// reading email
       //creating Doctor object
       Doctor doctor=new Doctor(name,phone,email);
       System.out.print("Enter Name :");
       String name1 = kb.nextLine();// reading name
       // asking user phone
       System.out.print("Enter Phone :");
       String phone1 = kb.nextLine();// reading phone
       // asking user email
       System.out.print("Enter Email :");
       String email1 = kb.nextLine();// reading email
       // asking user Staff Number
       System.out.print("Enter Staff Number :");
       String staffNumber = kb.nextLine();// reading staff number
       // asking user page number
       System.out.print("Enter Page Number :");
       String pageNumber = kb.nextLine();// reading email
       //creating Doctor object
       HospitalDoctor hospitalDoctor=new HospitalDoctor(name1,phone1,email1,staffNumber,pageNumber);
       //printing Doctor objects
       System.out.println(doctor.toString());
       //print HospitalDoctor object
       System.out.println(hospitalDoctor.toString());
      
      

   }
}

=================================

Output 1:

Console X D Debug Shell | | | | | E = = = = E F <terminated> Q1Runner (Java Application] C:\Program Files\Java\jdk1.8.0_181\b

Add a comment
Know the answer?
Add Answer to:
Must be in Java. Please show step by step process with proper explanation and comments. Please...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description:...

    This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description: Write a program that uses inheritance features of object-oriented programming, including method overriding and polymorphism. Console Welcome to the Person Tester application Create customer or employee? (c/e): c Enter first name: Frank Enter last name: Jones Enter email address: frank44@ hot mail. com Customer number: M10293 You entered: Name: Frank Jones Email: frank44@hot mail . com Customer number: M10293 Continue? (y/n): y Create customer...

  • Must be in Java. Show proper reasoning with step by step process. Comment on the code...

    Must be in Java. Show proper reasoning with step by step process. Comment on the code please and show proper indentation. Use simplicity. Must match the exact Output. CODE GIVEN: LineSegment.java LineSegmentTest.java Point.java public class Point { private double x, y; // x and y coordinates of point /** * Creates an instance of Point with the provided coordinates * @param inX the x coordinate * @param inY the y coordinate */ public Point (double inX, double inY) { this.x...

  • Must be done in Java. Provide the rest of the code with full comments and explanation and with proper indentation. Use...

    Must be done in Java. Provide the rest of the code with full comments and explanation and with proper indentation. Use simple methods for better understanding. Must compile. CODE PROVIDED: import java.util.ArrayList; import java.util.Scanner; public class Problem3 {    public static void main( String [] args ) {        Scanner in = new Scanner( System.in );        //PLEASE START YOUR WORK HERE        //**********************************************************                                                  //**********************************************************        // PLEASE END YOUR WORK HERE        System.out.print("END OF OUTPUT");    } } 20 points! PROBLEM 3: EXTENDED FAMILY Complete this...

  • HospitalEmployee Inheritance help please. import java.text.NumberFormat; public class HospitalEmployee {    private String empName;    private...

    HospitalEmployee Inheritance help please. import java.text.NumberFormat; public class HospitalEmployee {    private String empName;    private int empNumber;    private double hoursWorked;    private double payRate;       private static int hospitalEmployeeCount = 0;    //-----------------------------------------------------------------    // Sets up this hospital employee with default information.    //-----------------------------------------------------------------    public HospitalEmployee()    { empName = "Chris Smith"; empNumber = 9999; hoursWorked = 0; payRate =0;               hospitalEmployeeCount++;    }       //overloaded constructor.    public HospitalEmployee(String eName,...

  • Code in JAVA UML //TEST HARNESS //DO NOT CHANGE CODE FOR TEST HARNESS import java.util.Scanner; //...

    Code in JAVA UML //TEST HARNESS //DO NOT CHANGE CODE FOR TEST HARNESS import java.util.Scanner; // Scanner class to support user input public class TestPetHierarchy { /* * All the 'work' of the process takes place in the main method. This is actually poor design/structure, * but we will use this (very simple) form to begin the semester... */ public static void main( String[] args ) { /* * Variables required for processing */ Scanner input = new Scanner( System.in...

  • using C#, implement classes as shown below: Ready to pay as 4 questions for this (not...

    using C#, implement classes as shown below: Ready to pay as 4 questions for this (not only 1), just tell me how can I pay the other 3. nterface Order +make Order): string +make Payment (double amount): string Contact +contactID: integer name:string +address: string +phoneNum :string +Contact(int id, string name, st ring address, string phoneNum) +To String): string Customer Vendor +Customer (int id, st ring name, string address, string phoneNum) A +Vendor int id, string name, string address, string phoneNum)...

  • JAVA :The following are descriptions of classes that you will create. Think of these as service...

    JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...

  • JAVA... QUESTION 3 IS A CONTINOUS TO Q2 CAN YOU SEND THE CODE SEPARATELY FOR EACH...

    JAVA... QUESTION 3 IS A CONTINOUS TO Q2 CAN YOU SEND THE CODE SEPARATELY FOR EACH Q , I BE SO THANKFUL Q2. Implement a program to store the applicant’s information for a visa office. You need to implement the following: A super class called Applicant, which has the following instance variables: A variable to store first name of type String. A variable to store last name of type String. A variable to store date of birth, should be implemented...

  • I need help for part B and C 1) Create a new project in NetBeans called...

    I need help for part B and C 1) Create a new project in NetBeans called Lab6Inheritance. Add a new Java class to the project called Person. 2) The UML class diagram for Person is as follows: Person - name: String - id: int + Person( String name, int id) + getName(): String + getido: int + display(): void 3) Add fields to Person class. 4) Add the constructor and the getters to person class. 5) Add the display() method,...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT