Programming logic | Computer Science homework help

1. Find the bugs(5bugs)


// A Patient class is used by a doctor’s office.

// The Patient class has two overloaded constructors:

//    1) a default constructor,

//    2) one that requires an ID number, first and last name.

// A demonstration program declares two Patient objects

// and displays each patient’s data fields.



      Patient patient1()

      Patient patient2(“234”, “Lee”, “Lydia”)




class Patient


      private string idNum

      private string lastName

      private string firstName

   public Patient()

      idNum = “0000”

      lastName = “XXXX”

      firstName = “XXXX”


   public Patient(string id, string last, string first)

      idNum = idNum

      last = last

      firstName = first


 public void display()

      output “Patient #”, id, lastName, firstName




2. 2a and 2b were shown or done in class. 2c & 2d are for your homework 


a. Design a class named PhoneCall with four fields: two strings that hold the 10-digit phone 

numbers that originated and received the call, and two numeric fields that hold the length of the 

call in minutes and the cost of the call. Include a constructor that sets the phone numbers to Xs 

and the numeric fields to 0. Include get and set methods for the phone numbers and call length 

fields and a get method for the cost, but do not include a set method for the cost field. When 

the call length is set, calculate the cost of the call at three cents per minute for the first 10 

minutes, and two cents per subsequent minute. Create the class diagram and write the 

pseudocode that defines the class. 


Answer: A sample solution follows 





-origCall: string 

-recCall: string 

-length: num 

-cost: num 


+setOrigCall(number : string) : void 

+setRecCall(number : string) : void 

+setLength(len : num) : void 

+getOrigCall() : string 

+getRecCall() : string 

+getLength() : num 

+getCost() : num 





class PhoneCall 


private string origCall 

private string recCall 

private num length 

private num cost 


public PhoneCall() 

 origCall = “XXXXXXXXXX” 

 recCall = “XXXXXXXXXX” 

 length = 0 

 cost = 0 



public void setOrigCall(string number) 

 origCall = number 



public void setRecCall(string number) 

 recall = number 



public void setLength(num len) 


 num LIMIT = 10 

 num LIMIT_OR_LESS = .03 

 num MORE_THAN_LIMIT = .02 

 length = len 

 if length > LIMIT then 

 cost = (LIMIT_OR_LESS * LIMIT) + 

 (MORE_THAN_LIMIT * (length – LIMIT)) 


 cost = LIMIT_OR_LESS * length 





public string getOrigCall() 

return origCall 


public string getRecCall() 

return recCall 


public num getLength() 

return length 


public num getCost() 

return cost 



b. Design an application that declares three PhoneCalls. Set the length of one PhoneCall 

to 10 minutes, another to 11 minutes, and allow the third object to use the default value 

supplied by the constructor. Then, display each PhoneCall’s values. 


Answer: A sample solution follows 






PhoneCall callOne 

 PhoneCall callTwo 

 PhoneCall callThree 





 output “PhoneCall 1 info:” 

 output “Originating number = ”, callOne.getOrigCall() 

 output “Receiving number = ”, callOne.getRecCall() 

 output “Call length = ”, callOne.getLength() 

 output “Call cost = ”, callOne.getCost() 


 output “PhoneCall 2 info:” 

 output “Originating number = ”, callTwo.getOrigCall() 

 output “Receiving number = ”, callTwo.getRecCall() 

 output “Call length = ”, callTwo.getLength() 

 output “Call cost = ”, callTwo.getCost() 


 output “PhoneCall 3 info:” 

 output “Originating number = ”, Chapter 11 – Part 2, Exam Question #2 – Fall 2013


 output “Receiving number = ”, callThree.getRecCall() 

 output “Call length = ”, callThree.getLength() 

 output “Call cost = ”, callThree.getCost() 





Here is your assignment using the above 2a and 2b as the starting point/basis: 


c. Create a child class named InternationalPhoneCall. Override the parent class 

method that sets the call length to calculate the cost of the call at 40 cents per minute. 

Create the Class Diagram for the child class and write the pseudocode for the child 



d. Create the logic for an application that instantiates a PhoneCall object and an 


InternationalPhoneCall object and displays the costs for both. 

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.