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. 

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more